﻿/*
* Author:wubiyu
* Tel:13548186770
* QQ:175930190
* Date:2011/05/16
* Dom helper JavaScript Library v2.0 
* 修改接口
*/
//hdomext framework
(function (window, undefined) {
    //定义框架库名为 hyJsFramework , d＝document对象
    var hyJsFramework = {},
     h = hyJsFramework,
     d = window.document,
    _hname = "window._h",
    _gname = "window._g",
    idOrcsskExp = /^#([\w-]+)$|^\.([\w-]+)$|^>(.+)$|^_([\w-]+)$/,
    tagNameExp = /^h:(\w+)$/,
    toString = Object.prototype.toString,
    hasOwnProperty = Object.prototype.hasOwnProperty,
	push = Array.prototype.push,
	slice = Array.prototype.slice,
	indexOf = Array.prototype.indexOf;
    var jsc = now(),
	rscript = /<script(.|\s)*?\/script>/gi,
	rselectTextarea = /select|textarea/i,
	rinput = /color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,
	jsre = /=\?(&|$)/,
	rquery = /\?/,
	rts = /(\?|&)_=.*?(&|$)/,
	rurl = /^(\w+:)?\/\/([^\/?#]+)/,
	r20 = /%20/g,
    rnotwhite = /\S/;
    h.Ver = "2.0";
    h.tagName = "h:"; //自定义标签名称
    //Begin 初始化浏览器版本

    h.IsIE6 = false;
    h.IsIE7 = false;
    h.IsMozillaSafari = false;
    if (window.XMLHttpRequest) { //Mozilla, Safari, IE7
        if (!window.ActiveXObject) { // Mozilla, Safari,
            h.IsMozillaSafari = true;
        } else {
            h.IsIE7 = true;
        }
    } else {
        h.IsIE6 = true;
    }
    ///End 初始化浏览器版本

    //#region Dom 加载完成就开始执行。
    var isReady = false; //判断onDOMReady方法是否已经被执行过  
    var readyList = []; //把需要执行的方法先暂存在这个数组里  
    var timer; //定时器句柄

    h.ready = function (fn) {
        if (isReady) {
            fn.call(d, h, g);
        }
        else
            readyList.push(fn);
        return h;
    };
    var onDOMReady = function () {
        for (var i = 0; i < readyList.length; i++) {
            readyList[i].call(d, h, g);
        }
        readyList = null;
    };
    var bindReady = function (evt) {
        if (isReady) return;
        isReady = true;
        onDOMReady.call(window);
        if (d.removeEventListener) {
            d.removeEventListener("DOMContentLoaded", bindReady, false);
        } else if (d.attachEvent) {
            d.detachEvent("onreadystatechange", bindReady);
            if (window == window.top) {
                clearInterval(timer);
                timer = null;
            }
        };
    };
    //设置DOM 加载监听事件。  
    var OninitLoadReady = function () {
        if (d.addEventListener) {
            d.addEventListener("DOMContentLoaded", bindReady, false);
        } else if (d.attachEvent) {
            d.attachEvent("onreadystatechange", function () {
                if ((/loaded|complete/).test(d.readyState))
                    bindReady();
            });
            if (window == window.top) {
                timer = setInterval(function () {
                    try {
                        isReady || d.documentElement.doScroll('left'); //在IE下用能否执行doScroll判断dom是否加载完毕  
                    } catch (e) {
                        return;
                    }
                    bindReady();
                }, 5);
            }
        }
    };
    OninitLoadReady(); //设置DOM 加载监听事件。
    //#endregion Dom 加载完成就开始执行。

    //#region 定义选择器对象
    var gTagName = function (tname) {
        var match;
        match = tagNameExp.exec(tname.toLowerCase());
        if (match)
            return { IE: match[1], FireFox: match[0] };
        else
            return { IE: tname, FireFox: h.tagName + tname };
    };
    h.GetTagName = function (e) {
        var t = gTagName(e.tagName);
        return t.FireFox.toLowerCase();
    }
    var g = function (selector, context) {

        var match, elem;
        if (selector.nodeType) {
            h.Extend(selector, h.Defui["default"]);
            return selector;
        }
        match = idOrcsskExp.exec(selector);
        if (match && match[1]) //select #id 
        {
            //d.writeln("select #id:" + match[1] + "<br/>");
            if(context != undefined && context.domain != null)
                elem = context.getElementById(match[1]);
            else
                elem = d.gid(match[1]);
            h.Extend(elem, h.Defui["default"]);
            return elem;
        }
        else if (match && match[2])//select .class
        {
            selector = match[2];
            var objs = d.gtags("*", context);
            elem = new Array();
            for (var i = 0; i < objs.length; i++) {
                if (objs[i].className == selector) {
                     h.Extend(objs[i], h.Defui["default"]);
                     elem.push(objs[i]);
                }
            }
            h.DefinCollectionFnExtend(elem, h.Defui["default"].DomCollectionFn);
            return elem;
        }
        else  if (match && match[3]) // select fister layer nodes
        {
            context = context == undefined ? d.body : context;
            var c =context.childNodes;

            elem = new Array();
            for(var i =0;i<c.length;i++)
            {
                if(c[i].nodeType ==1)
                {
                    if(h.GetTagName(c[i]) == match[3].toLowerCase())
                    {
                        h.Extend(c[i], h.Defui["default"]);
                        elem.push(c[i]);
                    }
                }
            }
            h.DefinCollectionFnExtend(elem, h.Defui["default"].DomCollectionFn);
            return elem;
        }else if (match && match[4]){

            if(context != undefined && context.domain != null)
            {
                elem = context.getElementsByName(match[4]);
            }
            else
            {
                elem = d.gname(match[4]);
            }

            h.DefinCollectionFnExtend(elem, h.Defui["default"].DomCollectionFn);

            return elem;

        } else{
            elem = d.gtags(selector, context);
            h.DefinCollectionFnExtend(elem, h.Defui["default"].DomCollectionFn);
            return elem;
        }
    };
    h.d = d;
    d.gid = function (id) { return d.getElementById(id); };
    d.gname = function (name) { return d.getElementsByName(name); };
    d.gtags = function (tags, context) {
        context = context == undefined ? d.body : context;
        if (tags === "*") context = d.body;
        tags = gTagName(tags);
        var objs = context.getElementsByTagName(tags.IE);
        if (objs.length <= 0) {
            return context.getElementsByTagName(tags.FireFox);
        }
        return objs;
    };
    //#endregion 定义选择器对象
    //#region 定义h.support对象
    function now() {
        return (new Date).getTime();
    };
    (function () {

        h.support = {};

        var root = document.documentElement,
		        script = document.createElement("script"),
		        div = document.createElement("div"),
		        id = "script" + now();
        div.style.display = "none";
        div.innerHTML = "   <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
        var all = div.getElementsByTagName("*"),
		         a = div.getElementsByTagName("a")[0];

        // Can't get basic test support
        if (!all || !all.length || !a) {
            return;
        }

        h.support = {
            // IE strips leading whitespace when .innerHTML is used
            leadingWhitespace: div.firstChild.nodeType === 3,

            // Make sure that tbody elements aren't automatically inserted
            // IE will insert them into empty tables
            tbody: !div.getElementsByTagName("tbody").length,

            // Make sure that link elements get serialized correctly by innerHTML
            // This requires a wrapper element in IE
            htmlSerialize: !!div.getElementsByTagName("link").length,

            // Get the style information from getAttribute
            // (IE uses .cssText insted)
            style: /red/.test(a.getAttribute("style")),

            // Make sure that URLs aren't manipulated
            // (IE normalizes it by default)
            hrefNormalized: a.getAttribute("href") === "/a",

            // Make sure that element opacity exists
            // (IE uses filter instead)
            // Use a regex to work around a WebKit issue. See #5145
            opacity: /^0.55$/.test(a.style.opacity),

            // Verify style float existence
            // (IE uses styleFloat instead of cssFloat)
            cssFloat: !!a.style.cssFloat,

            // Make sure that if no value is specified for a checkbox
            // that it defaults to "on".
            // (WebKit defaults to "" instead)
            checkOn: div.getElementsByTagName("input")[0].value === "on",

            // Make sure that a selected-by-default option has a working selected property.
            // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
            optSelected: document.createElement("select").appendChild(document.createElement("option")).selected,

            // Will be defined later
            checkClone: false,
            scriptEval: false,
            noCloneEvent: true,
            boxModel: null
        };

        script.type = "text/javascript";
        try {
            script.appendChild(document.createTextNode("window." + id + "=1;"));
        } catch (e) { }

        root.insertBefore(script, root.firstChild);

        // Make sure that the execution of code works by injecting a script
        // tag with appendChild/createTextNode
        // (IE doesn't support this, fails, and uses .text instead)
        if (window[id]) {
            h.support.scriptEval = true;
            delete window[id];
        }

        root.removeChild(script);
        if (div.attachEvent && div.fireEvent) {
            div.attachEvent("onclick", function click() {
                // Cloning a node shouldn't copy over any
                // bound event handlers (IE does this)
                h.support.noCloneEvent = false;
                div.detachEvent("onclick", click);
            });
            div.cloneNode(true).fireEvent("onclick");
        }

        div = document.createElement("div");
        div.innerHTML = "<input type='radio' name='radiotest' checked='checked'/>";

        var fragment = document.createDocumentFragment();
        fragment.appendChild(div.firstChild);

        // WebKit doesn't clone checked state correctly in fragments
        h.support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked;

        // Figure out if the W3C box model works as expected
        // document.body must exist before we can do this
        //                h(function () {
        //                    var div = document.createElement("div");
        //                    div.style.width = div.style.paddingLeft = "1px";

        //                    document.body.appendChild(div);
        //                    h.boxModel = h.support.boxModel = div.offsetWidth === 2;
        //                    document.body.removeChild(div).style.display = 'none';
        //                    div = null;
        //                });
        // Technique from Juriy Zaytsev
        var eventSupported = function (eventName) {
            var el = document.createElement("div");
            eventName = "on" + eventName;

            var isSupported = (eventName in el);
            if (!isSupported) {
                el.setAttribute(eventName, "return;");
                isSupported = typeof el[eventName] === "function";
            }
            el = null;

            return isSupported;
        };

        h.support.submitBubbles = eventSupported("submit");
        h.support.changeBubbles = eventSupported("change");

        // release memory in IE
        root = script = div = all = a = null;
    })();
    //#endregion 定义h.support对象
    //#region 定义 hyJsFramework 公共函数

    //#region 定义页对象
    h.Page = h.Page || {};
    //当前页的鼠标当前x位置
    h.Page.MouseX = 0;
   //当前页的鼠标当前Y位置
    h.Page.MouseY = 0;
    h.Page.MouseFollowObj = null;
    h.Page.MouseMoveHandle = null;
    h.Page.MouseUpHandle = null;
    h.Page.InitHandle = null;
    h.Page.OnLoadHandle = null;
    h.Page.OnMouseMove = function () {
        try {
            e = h.GetEvent();
            //h.Page.MouseX = d.body.scrollLeft + e.clientX;
            //h.Page.MouseY = d.body.scrollTop + e.clientY;
            h.Page.MouseX = h.GetScrollXY().x + e.clientX;
            h.Page.MouseY = h.GetScrollXY().y + e.clientY;
            if (h.Drag.Start) {
                h.Drag.Fn(h.Drag.Data);
            }
            if (h.Page.MouseMoveHandle != null)
            {
                h.Page.MouseMoveHandle();
             }       
        }
        catch (e) { }
    };
    h.Page.OnMouseUp = function () {

        h.Drag.Stop();
        if (h.Page.MouseUpHandle != null)
        {
            h.Page.MouseUpHandle();
        }
    };
    h.Page.OnKeyDown=function()
    {
        var  e = h.GetEvent();
        var key = h.key.GetKeyCode(e);
        var kshift = 0,kctrl=0,katl=0;
        if (e.shiftKey) {
            kshift=1;
        }
        if (e.ctrlKey) {
            kctrl=1;
        }
        if (e.altKey) {
            katl=1;
        }
        var keyCode = kshift.toString()+kctrl.toString()+katl.toString()+key.toString();
        if(h.key.Group[h.key.CurrentGroup] == null) return;
        var keyobj = h.key.Group[h.key.CurrentGroup][keyCode];
        if(keyobj !=null)
        {
            if(keyobj.isRuning == false)
            {
                keyobj.isRuning=true;
                keyobj.keyfn(e,keyobj);
                keyobj.isRuning=false;
                e.returnValue=false;
            }
        }
    };
    h.Page.OnClick=function(){
        var menus = g("h:menu");
        h.eachAsy(menus,function(i){
            h.Menu.HidStacksMenu(menus[i]);
        },null,null);
    };
    h.Page.OnReSize=function(){
       var p = _h.GetPageSize();
       if(h.Page.ReSizeHandle !=null)
            h.Page.ReSizeHandle(p);
    };
    h.Page.ReSizeHandle = null;
    //#endregion 定义页对象

    //#region 定义window.setInterval管理对象。
    h.IntervalObjs = {}; 
    h.IntervalObjs.length=0;
    h.AddInterval = function (name, fn, delay) {
        if (h.IntervalObjs[name] == undefined || h.IntervalObjs[name] == null)
        {
            h.IntervalObjs[name] = window.setInterval(fn, delay);
            h.IntervalObjs.length++;
        }
        return name;
    };
    h.ClearInterval = function (name) {
        if (h.IntervalObjs[name] != undefined || h.IntervalObjs[name] != null) {
            window.clearInterval(h.IntervalObjs[name]);
            delete h.IntervalObjs[name];
            h.IntervalObjs.length--;
        }
        return null;
    };
    //endregion 定义window.setInterval管理对象。
    //#region 定义window.setTimeout管理对象。
    h.SetTimeoutObjs={};
    h.SetTimeoutObjs.length=0;
    h.AddSetTimeout = function (name, fn, delay) {
        if (h.SetTimeoutObjs[name] == undefined || h.SetTimeoutObjs[name] == null)
        {
            h.SetTimeoutObjs[name] = window.setTimeout(fn, delay);
            h.SetTimeoutObjs.length++;
        }
        return name;
    };
    h.ClearSetTimeout = function (name) {
        if (h.SetTimeoutObjs[name] != undefined || h.SetTimeoutObjs[name] != null) {
            window.clearTimeout(h.SetTimeoutObjs[name]);
            delete h.SetTimeoutObjs[name];
            h.SetTimeoutObjs.length--;
        }
        return null;
    };
    //#endregion 定义window.setTimeout管理对象。
    //#region 拖动对象
    h.Drag = h.Drag || {};
    h.Drag.Data = null; //拖动时传递的数据
    h.Drag.Start = null; //设置为开始拖动状态
    h.Drag.Fn = null; //开始拖动时触发的事件句柄。通常为鼠标按下时。
    h.Drag.EscFn = null; //结束拖动时触发的事件句柄。通常为鼠标在目标对象上释放时。
    h.Drag.BodyStyle="";
    h.OnSelectStart = function () {
        return false;
    };
    //拖动核心方法，设置相应该的属性。
    h.Drag.SetData = function (dragData, fn, escFn) {
        h.IsSelectionTest(d.body,false);
        d.body.style.cssText = d.body.style.cssText+"-moz-user-select:none;";
        h.Drag.Data = dragData;
        dragData.MouseX = h.Page.MouseX;
        dragData.MouseY = h.Page.MouseY;
        h.Drag.Start = true;
        h.Drag.Fn = fn;
        h.Drag.EscFn = escFn;
    };
    h.Drag.GetData = function () {
        return h.Drag.Data;
    };
    h.Drag.Stop = function () {
        if (h.Drag.EscFn != null) {
            h.Drag.EscFn(h.Drag.Data);
            h.Drag.EscFn=null;
        }
        h.Drag.Start = false;
        h.Drag.Data = null;
        h.Drag.Fn = null;
        h.IsSelectionTest(d.body,true);
    };
    //禁止选择文本
    h.IsSelectionTest = function (target,isSelect){ 
        if(isSelect== true)
        {
            if (typeof target.onselectstart!="undefined") //IE route 
            target.onselectstart=function(){return true;};
            else if (typeof target.style.MozUserSelect!="undefined") //Firefox route 
                target.style.MozUserSelect=""; 
            else //All other route (ie: Opera) 
                target.onmousedown=function(){return true}; 
            target.style.cursor = "";  
        }
        if(isSelect == false)
        {
            if (typeof target.onselectstart!="undefined") //IE route 
                target.onselectstart=function(){return false;}; 
            else if (typeof target.style.MozUserSelect!="undefined") //Firefox route 
                target.style.MozUserSelect="none"; 
            else //All other route (ie: Opera) 
                target.onmousedown=function(){return false;}; 
            target.style.cursor = "default"; 
        }
    };
    //#endregion 拖动对象

    //解析模板。并将数据源中对应该的值填入。dataSource 是一个Array,rowsIndex 是索引值。
    //模板格式为：<a href=''>{=Name} l{=[0]}l</a>
    h.tempDataSource = null;
    h.GetDataFromTemplet = function (str, rowsIndex, dataSource) {
        var resaultStr = GetDataFormEmbedTempTemplet(str, rowsIndex, dataSource, false);
        resaultStr = GetUnDataFormEmbedTempTemplet(resaultStr);
        return resaultStr.Trim(" ","");
    };
    function GetDataFormEmbedTempTemplet(str, rowsIndex, dataSource, isEmbedItemTemplet) {
        h.tempDataSource = dataSource;
        //var reg = new RegExp("\{=[A-z0-9\.\(\)]{1,}\}(?!.*\</h:itemtemplet[^>]*\>)|\{=[A-z0-9\.\(\)]{1,}\}(?=.*\<h:itemtemplet[^>]*\>)");
        var reg = new RegExp("\{=[A-z0-9\.\(\)]{1,}\}|(<h:itemtemplet)|(</h:itemtemplet)");
        var temp = str.match(reg);
        if (temp == null)
            return str;
        else {
            temp[0] = temp[0].replace(" ", "");
            if (temp[0] == "<h:itemtemplet") {
                str = str.replace(reg, "<TempItemtemplet");
                isEmbedItemTemplet = true;
                return GetDataFormEmbedTempTemplet(str, rowsIndex, dataSource, isEmbedItemTemplet);
            }
            if (temp[0] == "</h:itemtemplet") {
                str = str.replace(reg, "</TempItemtemplet");
                isEmbedItemTemplet = false;
                return GetDataFormEmbedTempTemplet(str, rowsIndex, dataSource, isEmbedItemTemplet);
            }
            var tempField = temp[0].substring(2, temp[0].length - 1);
            var tempData = "";
            try{
                if (tempField == "CurrentIndex")
                    tempData = rowsIndex;
                else {
                    if (tempField.substr(0, 1) == '[') {
                        tempData = eval(_hname + ".tempDataSource[" + rowsIndex + "]" + tempField);
                    }
                    else {
                        tempData = eval(_hname + ".tempDataSource[" + rowsIndex + "]." + tempField);
                    }
                }
           
                if (isEmbedItemTemplet == false)
                    str = str.replace(reg, tempData);
                else {
                    str = str.replace(reg, "<TempletData>=" + tempField + "</TempletData>");
                }
             }catch(e){ return "";}
            return GetDataFormEmbedTempTemplet(str, rowsIndex, dataSource, isEmbedItemTemplet);
        }
    };
    function GetUnDataFormEmbedTempTemplet(str) {
        var reg = RegExp("(<TempItemtemplet)|(</TempItemtemplet)|(<TempletData>)|(</TempletData>)");
        var temp = str.match(reg);
        if (temp == null)
            return str;
        else {
            temp[0] = temp[0].replace(" ", "");
            if (temp[0] == "<TempItemtemplet")
                str = str.replace(reg, "<h:itemtemplet");
            if (temp[0] == "</TempItemtemplet")
                str = str.replace(reg, "</h:itemtemplet");
            if (temp[0] == "<TempletData>")
                str = str.replace(reg, "{");
            if (temp[0] == "</TempletData>")
                str = str.replace(reg, "}");
            return GetUnDataFormEmbedTempTemplet(str);
        }
    };
    //获取 IE 地址中的根http://www.google.com/index 
    /*return http://www.google.com*/
    h.GetUrlRoot = function () {
        var url = new String(window.location);
        var index = url.indexOf("/", 7);
        if (index == -1)
            return url;
        else
            return url.substring(0, index);
    };
    //获取相对路径 
    //path:~/hom/index
    /*return:http://www.dd.com/home/index */
    h.ResolveClientUrl = function (path) {
        var str = new String(path);
        var root = h.GetUrlRoot();
        return root + str.substring(1, str.length);
    };
    //跳转的指定URL地址
    h.Redirect = function (url) {
        if (url == -1) {
            window.location = h.GetCookie("UrlPagePreview");
        }
        else {
            h.SetCookie("UrlPagePreview", window.location);
            window.location = url;
        }
    }
    //设置Cookie
    h.SetCookieVal = function (name, value, x_expires, x_path, x_domain, x_secure) {
        if (navigator.cookieEnabled == false) { return false; }
        //设置一个Cookie值函数
        //alert(name)
        var argv = h.SetCookieVal.arguments;
        //alert(this.argv);
        var argc = h.SetCookieVal.arguments.length;
        var expires = (argc > 2) ? x_expires : null;
        var path = (argc > 3) ? x_path : null;
        var domain = (argc > 4) ? x_domain : null;
        var secure = (argc > 5) ? x_secure : false;
        d.cookie = name + "=" + escape(value) +
                                  ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
                                  ((path == null) ? "" : ("; path=" + path)) +
                                  ((domain == null) ? "" : ("; domain=" + domain)) +
                                  ((secure == true) ? "; secure" : "");
        return true;
    };
    //设置Cookie
    h.SetCookie = function (name, value, expireDate) {
        if(expireDate == null || expireDate == undefined)
        {
            expireDate = new Date();
            expireDate.DateAdd("y",1);
       }
        return h.SetCookieVal(name, value, expireDate, "/");
    };
    //获取Cookie的值
    h.GetCookie = function (name) {
        //读取指定名称的cookie值函数
        //alert(document.cookie)
        var arg = name + "=";
        var alen = arg.length;
        var clen = d.cookie.length;
        var i = 0;
        while (i < clen) {
            var j = i + alen;
            if (d.cookie.substring(i, j) == arg) {
                return h.GetCookieVal(j);
            }
            i = d.cookie.indexOf(";", i);
            if (i == -1) break;
            i += 2;
        }
        return null;
    };
    h.GetCookieVal = function (offset) {
        if (navigator.cookieEnabled == false) { alert('not support Cookie'); return; }
        var endstr = d.cookie.indexOf(";", offset);
        if (endstr == -1)
            endstr = d.cookie.length;
        return unescape(d.cookie.substring(offset, endstr));
    };
    //删除Cookie值
    h.DelCookie = function (name) {
        if (navigator.cookieEnabled == false) { return false}
        var exp = new Date();
        exp.setTime(exp.getTime() - 1);
        return h.SetCookie(name,"",exp);
    };
    h.GetPageSize = function () {
        var xScroll, yScroll;
        if (window.innerHeight && window.scrollMaxY) {
            xScroll = d.body.scrollWidth;
            yScroll = window.innerHeight + window.scrollMaxY;
        }
        else if (d.body.scrollHeight > d.body.offsetHeight) {
            xScroll = d.body.scrollWidth;
            yScroll = d.body.scrollHeight;
        }
        else {
            xScroll = d.body.offsetWidth;
            yScroll = d.body.offsetHeight;
        }
        var windowWidth, windowHeight;
        if (self.innerHeight) {
            windowWidth = self.innerWidth;
            windowHeight = self.innerHeight;
        }
        else if (d.documentElement && d.documentElement.clientHeight) {
            windowWidth = d.documentElement.clientWidth;
            windowHeight = d.documentElement.clientHeight;
        }
        else if (d.body) {
            windowWidth = d.body.clientWidth;
            windowHeight = d.body.clientHeight;
        }
        if (yScroll < windowHeight) {
            pageHeight = windowHeight;
        }
        else {
            pageHeight = yScroll;
        }
        if (xScroll < windowWidth) {
            pageWidth = windowWidth;
        }
        else {
            pageWidth = xScroll;
        }
        return { pw: pageWidth, ph: pageHeight, ww: windowWidth, wh: windowHeight };
    }
    h.GetScrollXY = function () {
        var x, y;
        if (d.body.scrollTop) {
            x = d.body.scrollLeft;
            y = d.body.scrollTop;
        }
        else {
            x = d.documentElement.scrollLeft;
            y = d.documentElement.scrollTop;
        }
        return { x: x, y: y };
    }
    h.GetScrollWH = function () {
        var x, y;
        if (document.body.scrollTop) {
            x = d.body.scrollWidth;
            y = d.body.scrollHeight;
        }
        else {
            x = d.documentElement.scrollWidth;
            y = d.documentElement.scrollHeight;
        }
        return { w: x, h: y };
    }
    h.InitScrollBarWH=function()
    {
        /* 
        This function calculates window.scrollbarWidth and window.scrollbarHeight 
 
        This must be called "onload" to work correctly (or on "DOM ready", if you're using 
        a framework that provides such an event) 
        */ 
 
        var i = document.createElement('p'); 
        i.style.width = '100%'; 
        i.style.height = '200px'; 
 
        var o = document.createElement('div'); 
        o.style.position = 'absolute'; 
        o.style.top = '0px'; 
        o.style.left = '0px'; 
        o.style.visibility = 'hidden'; 
        o.style.width = '200px'; 
        o.style.height = '150px'; 
        o.style.overflow = 'hidden'; 
        o.appendChild(i); 
 
        document.body.appendChild(o); 
        var w1 = i.offsetWidth; 
        var h1 = i.offsetHeight; 
        o.style.overflow = 'scroll'; 
        var w2 = i.offsetWidth; 
        var h2 = i.offsetHeight; 
        if (w1 == w2) w2 = o.clientWidth; 
        if (h1 == h2) h2 = o.clientWidth; 
 
        document.body.removeChild(o); 
 
        h.Page.scrollbarWidth = w1-w2; 
        h.Page.scrollbarHeight = h1-h2; 
    };
    h.GetUrlParam = function () {
        var param = new Object();
        var l = new String(window.location);
        var pstr = new String(l.substring(l.lastIndexOf('?') + 1, l.length));
        if (pstr.valueOf() === l.valueOf()) {
            alert("get url paramter not found " + l.valueOf());
            return null;
        }
        var parr = pstr.split('&');
        for (var i = 0; i < parr.length; i++) {
            var parrData = new Array();
            parrData = parr[i].toString().split('=');
            param[parrData[0]] = parrData[1];
        }
        return param;
    };
    //获取取事中的 event 参数
    h.GetEvent = function () {
        //同时兼容ie和ff的写法
        if (d.all) {
            var eArg = window.event;
            eArg.sender = eArg.srcElement || eArg.target;
            return eArg;
        }
        var func = h.GetEvent.caller;
        while (func != null) {
            var arg0 = func.arguments[0];
            if (arg0) {
                if ((arg0.constructor == Event || arg0.constructor == MouseEvent) || (typeof (arg0) == "object" && arg0.preventDefault && arg0.stopPropagation)) {
                    arg0.sender = arg0.srcElement || arg0.target;
                    return arg0;
                }
            }
            func = func.caller;
        }
        return null;
    };
    h.StopEvent=function()
    {
        var e=h.GetEvent();
        if (window.event) {
            e.cancelBubble=true;
        } else {
            e.stopPropagation();
        }
    };
    h.GetEventArg = function (e) {
        if(e == null || e == undefined)
            e = h.GetEvent();
        return e.srcElement || e.target;
    }
    h.CloseWindow = function () {
            var browserName = navigator.appName;
            if (browserName == "Netscape") {
                window.open("about:blank", "_top", "");
                window.parent.close();
            } else if (browserName == "Microsoft Internet Explorer") {
                window.opener = null;  
                window.open('', '_top', '');  
                window.parent.close(); 
            }
    };
//    h.GetRef = function (obj, func) {
//        if (obj.id == undefined || obj.id == null) {
//            alert("h.GetRef obj.id is null or undefined");
//            return null;
//        }
//        return new Function(func + "('" + obj.id + "'); ");
//    };
    //h.each(数组对象，处理函数，参数,完成的回);
    h.each = function (o, fn, args) {
        for (var key in o) {
            var rh = fn.call(d, key, o[key], args);
            if(rh == "break")
                break;
            if(rh="continue")
                continue;
        }
    };
    h.eachAsySetting = {runTime:25,waittingTime:25};
    h.eachAsy = function(ar,fn,callback,setObj)
    {
             var data = ar;
             var index=0;  
             var len = data.length;
             setTimeout(function(){
                var setting = h.extend(true,h.eachAsySetting,setObj);
                var start = +new Date();
                var item=data[index++];
                if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                do{
                    if(fn !=null)
                    { 
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                        var item=data[index++];
                        if(item == undefined || item == null){}else{fn.call(d,index-1,item);}
                    }
                }while(index <len && (+new Date() -start<setting.runTime));
                
                if(index<len)
                        setTimeout(arguments.callee,setting.waittingTime);
                else{
                        if(callback !=null)
                                callback.call();
                }
             },0);
           
    };
    h.StringBuilder = function(str)
    {
        this.data = new Array();
        this.Add=function(str){
            if(str != null || str != undefined)
            {
                if(h.isArray(str))
                {
                    this.data.push(str.join(""));
                }else
                {
                    this.data.push(str);
                }
            }
        };
        this.Add(str);
        this.ToString = function(){
           return this.data.join("");
        };
    };
    h.GetStyle=function(e,str){
        
    };
    h.SetStyle=function(e,str){
        
    };
    //合并对象，原形 h.extend([是否更新值]，目标对象，[object]....);
    h.extend = function () {
        var object, i = 1, arglen = h.extend.arguments.length, args = h.extend.arguments, isOverWrite = false, target = h;
        if (arglen == 1) {
            i = 0;
        }
        if (typeof args[0] === 'boolean') {
            target = args[1]; i = 2; isOverWrite = args[0];
        } else {
            target = args[0];
        }
        for (; i < args.length; i++) {
            _extend(target, args[i], isOverWrite);
        }
        return target;
    };
    h.extendfrm = function () {
        var object, i = 0, arglen = h.extendfrm.arguments.length, args = h.extendfrm.arguments, isOverWrite = false, target = h;
        for (; i < args.length; i++) {
            _extend(target, args[i], isOverWrite);
        }
        return target;
    };
    var _extend = function (elem, o, isoverwriter) {
        for (var key in o) {
            isoverwriter = isoverwriter ? isoverwriter : elem[key] == undefined;
            if (isoverwriter) {
                elem[key] = o[key];
            }
        }
        return elem;
    };
    h.addEvent = function (obj, eventName, fn, useCapture) {
        if(obj ==null) return false;
        if(fn == undefined) return false;
        useCapture = !useCapture ? false : true;
        if(eventName == obj.keyevent)
            h.key.Addkey(obj.keygroup,obj.keychar,fn);
        if (obj.addEventListener) {
            return obj.addEventListener(eventName, fn, useCapture);
        } else if (obj.detachEvent) {
            eventName = "on" + eventName;
            return obj.attachEvent(eventName, fn);
        }
        return false;
    };
    h.deleteEvent = function (obj, eventName, fn, useCapture) {
        useCapture = !useCapture ? false : true;
        if (obj.removeEventListener) {
            return obj.removeEventListener(eventName, fn, useCapture);
        } else if (obj.detachEvent) {
            eventName = "on" + eventName;
            return obj.detachEvent(eventName, fn);
        }
        return null;
    };
    h.isFunction = function (obj) {
        return toString.call(obj) === "[object Function]";
    };
    h.isArray = function (obj) {
        return toString.call(obj) === "[object Array]";
    };
    h.isEmptyObject = function (obj) {
        for (var name in obj) {
            return false;
        }
        return true;
    };
    //获取css文件中的值。注意css_file_id,是顺序加载的文档的索引值。
//    h.GetStyleValue = function (css_file_id, labname, param) {
//        var tar;
//        var rss;
//        var style;
//        var value;
//        tar = document.styleSheets[css_file_id];
//        alert( tar.cssRules);
//        rss = tar.cssRules ? tar.cssRules : tar.rules;
//        alert(rss);
//        for (i = 0; i < rss.length; i++) {
//            style = rss[i];
//            if (style.selectorText.toLowerCase() == labname.toLowerCase()) {
//                value = style.style[param];
//            }
//        }
//        return value;
//    };
    //获取HTML属性
    h.Attr = function (obj, name) {
        return obj.getAttribute(name);
    };
    //#region replace framework name
    h.Set_hname = function (newNameStr) {
        eval("window." + newNameStr + "=" + _hname);
        _hname = "window." + newNameStr;
    };
    h.Set_gname = function (newNameStr) {
        eval("window." + newNameStr + "=" + _gname);
        _gname = "window." + newNameStr;
    };
    //endreigon replace framework name
    //#region Ajax
    h.parseJSON = function (data) {
        if (typeof data !== "string" || !data) {
            return null;
        }
        // Make sure the incoming data is actual JSON
        // Logic borrowed from http://json.org/json2.js
        if (/^[\],:{}\s]*$/.test(data.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@")
			.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]")
			.replace(/(?:^|:|,)(?:\s*\[)+/g, ""))) {

            // Try to use the native JSON parser first
            return window.JSON && window.JSON.parse ?
				window.JSON.parse(data) :
				(new Function("return " + data))();

        } else {
            h.error("Invalid JSON: " + data);
        }
    };
    h.noop = function () { };
    // Evalulates a script in a global context
    h.globalEval = function (data) {
        if (data && rnotwhite.test(data)) {
            // Inspired by code by Andrea Giammarchi
            // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
            var head = document.getElementsByTagName("head")[0] || document.documentElement,
				    script = document.createElement("script");

            script.type = "text/javascript";

            if (h.support.scriptEval) {
                script.appendChild(document.createTextNode(data));
            } else {
                script.text = data;
            }

            // Use insertBefore instead of appendChild to circumvent an IE6 bug.
            // This arises when a base node is used (#2709).
            head.insertBefore(script, head.firstChild);
            head.removeChild(script);
        }
    };
    h.ajaxSetup = function (settings) {
        h.extend(true, h.ajaxSettings, settings);
    };
    h.ajaxSettings = {
        url: location.href,
        global: false,
        type: "GET",
        contentType: "application/x-www-form-urlencoded",
        processData: true,
        async: true,
        cache: false,
        /*
        timeout: 0,
        data: null,
        username: null,
        password: null, 
        */
        traditional: false,
      
        // Create the request object; Microsoft failed to properly
        // implement the XMLHttpRequest in IE7 (can't request local files),
        // so we use the ActiveXObject when it is available
        // This function can be overriden by calling jQuery.ajaxSetup
        xhr: window.XMLHttpRequest && (window.location.protocol !== "file:" || !window.ActiveXObject) ?
			    function () {
			        return new window.XMLHttpRequest();
			    } :
			    function () {
			        try {
			            return new window.ActiveXObject("Microsoft.XMLHTTP");
			        } catch (e) { }
			    },
        accepts: {
            xml: "application/xml, text/xml",
            html: "text/html",
            script: "text/javascript, application/javascript",
            json: "application/json, text/javascript",
            text: "text/plain",
            _default: "*/*"
        }
    };
    h.error = function (msg) {
        throw msg;
    };
    h.httpData = function (xhr, type, s) {
        var ct = xhr.getResponseHeader("content-type") || "",
			    xml = type === "xml" || !type && ct.indexOf("xml") >= 0,
			    data = xml ? xhr.responseXML : xhr.responseText;

        if (xml && data.documentElement.nodeName === "parsererror") {
            h.error("parsererror");
        }

        // Allow a pre-filtering function to sanitize the response
        // s is checked to keep backwards compatibility
        if (s && s.dataFilter) {
            data = s.dataFilter(data, type);
        }

        // The filter can actually parse the response
        if (typeof data === "string") {
            // Get the JavaScript object, if JSON is used.
            if (type === "json" || !type && ct.indexOf("json") >= 0) {
                data = h.parseJSON(data);

                // If the type is "script", eval it in global context
            } else if (type === "script" || !type && ct.indexOf("javascript") >= 0) {
                h.globalEval(data);
            }
        }

        return data;
    };
    h.handleError = function (s, xhr, status, e) {
        // If a local callback was specified, fire it
        if (s.error) {
            s.error.call(s.context || s, xhr, status, e);
        }

        // Fire the global callback
        //if (s.global) {
        //    (s.context ? jQuery(s.context) : jQuery.event).trigger("ajaxError", [xhr, s, e]);
        //}
    };
    h.httpSuccess = function (xhr) {
        try {
            // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
            return !xhr.status && location.protocol === "file:" ||
            // Opera returns 0 when status is 304
				(xhr.status >= 200 && xhr.status < 300) ||
				xhr.status === 304 || xhr.status === 1223 || xhr.status === 0;
        } catch (e) { }

        return false;
    };
    h.lastModified = {}; h.etag = {};
    // Determines if an XMLHttpRequest returns NotModified
    h.httpNotModified = function (xhr, url) {
        var lastModified = xhr.getResponseHeader("Last-Modified"),
			etag = xhr.getResponseHeader("Etag");

        if (lastModified) {
            h.lastModified[url] = lastModified;
        }

        if (etag) {
            h.etag[url] = etag;
        }

        // Opera returns 0 when status is 304
        return xhr.status === 304 || xhr.status === 0;
    };
    // Serialize an array of form elements or a set of
    // key/values into a query string
    h.param = function (a, traditional) {
        var s = [];

        // Set traditional to true for jQuery <= 1.3.2 behavior.
        if (traditional === undefined) {
            traditional = h.ajaxSettings.traditional;
        }

        // If an array was passed in, assume that it is an array of form elements.
        if (h.isArray(a)) {
            // Serialize the form elements
            h.each(a, function () {
                add(this.name, this.value);
            });

        } else {
            // If traditional, encode the "old" way (the way 1.3.2 or older
            // did it), otherwise encode params recursively.
            for (var prefix in a) {
                buildParams(prefix, a[prefix]);
            }
        }

        // Return the resulting serialization
        return s.join("&").replace(r20, "+");

        function buildParams(prefix, obj) {
            if (h.isArray(obj)) {
                // Serialize array item.
                h.each(obj, function (i, v) {
                    if (traditional) {
                        // Treat each array item as a scalar.
                        add(prefix, v);
                    } else {
                        // If array item is non-scalar (array or object), encode its
                        // numeric index to resolve deserialization ambiguity issues.
                        // Note that rack (as of 1.0.0) can't currently deserialize
                        // nested arrays properly, and attempting to do so may cause
                        // a server error. Possible fixes are to modify rack's
                        // deserialization algorithm or to provide an option or flag
                        // to force array serialization to be shallow.
                        buildParams(prefix + "[" + (typeof v === "object" || h.isArray(v) ? i : "") + "]", v);
                    }
                });

            } else if (!traditional && obj != null && typeof obj === "object") {
                // Serialize object item.
                h.each(obj, function (k, v) {
                    buildParams(prefix + "[" + k + "]", v);
                });

            } else {
                // Serialize scalar item.
                add(prefix, obj);
            }
        }

        function add(key, value) {
            // If value is a function, invoke it and return its value
            value = h.isFunction(value) ? value() : value;
            s[s.length] = encodeURIComponent(key) + "=" + encodeURIComponent(value);
        }
    };
    h.ajax = function (origSettings) {
        var s = h.extend(true, {}, h.ajaxSettings, origSettings);

        var jsonp, status, data,
			callbackContext = origSettings && origSettings.context || s,
			type = s.type.toUpperCase();

        // convert data if not already a string
        if (s.data && s.processData && typeof s.data !== "string") {
            s.data = h.param(s.data, s.traditional);
        }

        // Handle JSONP Parameter Callbacks
        if (s.dataType === "jsonp") {
            if (type === "GET") {
                if (!jsre.test(s.url)) {
                    s.url += (rquery.test(s.url) ? "&" : "?") + (s.jsonp || "callback") + "=?";
                }
            } else if (!s.data || !jsre.test(s.data)) {
                s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?";
            }
            s.dataType = "json";
        }

        // Build temporary JSONP function
        if (s.dataType === "json" && (s.data && jsre.test(s.data) || jsre.test(s.url))) {
            jsonp = s.jsonpCallback || ("jsonp" + jsc++);

            // Replace the =? sequence both in the query string and the data
            if (s.data) {
                s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1");
            }

            s.url = s.url.replace(jsre, "=" + jsonp + "$1");

            // We need to make sure
            // that a JSONP style response is executed properly
            s.dataType = "script";

            // Handle JSONP-style loading
            window[jsonp] = window[jsonp] || function (tmp) {
                data = tmp;
                success();
                complete();
                // Garbage collect
                window[jsonp] = undefined;

                try {
                    delete window[jsonp];
                } catch (e) { }

                if (head) {
                    head.removeChild(script);
                }
            };
        }

        if (s.dataType === "script" && s.cache === null) {
            s.cache = false;
        }

        if (s.cache === false && type === "GET") {
            var ts = now();

            // try replacing _= if it is there
            var ret = s.url.replace(rts, "$1_=" + ts + "$2");

            // if nothing was replaced, add timestamp to the end
            s.url = ret + ((ret === s.url) ? (rquery.test(s.url) ? "&" : "?") + "_=" + ts : "");
        }

        // If data is available, append data to url for get requests
        if (s.data && type === "GET") {
            s.url += (rquery.test(s.url) ? "&" : "?") + s.data;
        }

        // Watch for a new set of requests
        //if (s.global && !jQuery.active++) {
        //   jQuery.event.trigger("ajaxStart");
        //}

        // Matches an absolute URL, and saves the domain
        var parts = rurl.exec(s.url),
			    remote = parts && (parts[1] && parts[1] !== location.protocol || parts[2] !== location.host);

        // If we're requesting a remote document
        // and trying to load JSON or Script with a GET
        if (s.dataType === "script" && type === "GET" && remote) {
            var head = document.getElementsByTagName("head")[0] || document.documentElement;
            var script = document.createElement("script");
            script.src = s.url;
            if (s.scriptCharset) {
                script.charset = s.scriptCharset;
            }

            // Handle Script loading
            if (!jsonp) {
                var done = false;

                // Attach handlers for all browsers
                script.onload = script.onreadystatechange = function () {
                    if (!done && (!this.readyState ||
							this.readyState === "loaded" || this.readyState === "complete")) {
                        done = true;
                        success();
                        complete();

                        // Handle memory leak in IE
                        script.onload = script.onreadystatechange = null;
                        if (head && script.parentNode) {
                            head.removeChild(script);
                        }
                    }
                };
            }

            // Use insertBefore instead of appendChild  to circumvent an IE6 bug.
            // This arises when a base node is used (#2709 and #4378).
            head.insertBefore(script, head.firstChild);

            // We handle everything using the script element injection
            return undefined;
        }

        var requestDone = false;

        // Create the request object
        var xhr = s.xhr();

        if (!xhr) {
            return;
        }

        // Open the socket
        // Passing null username, generates a login popup on Opera (#2865)
        if (s.username) {
            xhr.open(type, s.url, s.async, s.username, s.password);
        } else {
            xhr.open(type, s.url, s.async);
        }

        // Need an extra try/catch for cross domain requests in Firefox 3
        try {
            // Set the correct header, if data is being sent
            if (s.data || origSettings && origSettings.contentType) {
                xhr.setRequestHeader("Content-Type", s.contentType);
            }

            // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
            if (s.ifModified) {
                if (h.lastModified[s.url]) {
                    xhr.setRequestHeader("If-Modified-Since", h.lastModified[s.url]);
                }

                if (h.etag[s.url]) {
                    xhr.setRequestHeader("If-None-Match", h.etag[s.url]);
                }
            }

            // Set header so the called script knows that it's an XMLHttpRequest
            // Only send the header if it's not a remote XHR
            if (!remote) {
                xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
            }

            // Set the Accepts header for the server, depending on the dataType
            xhr.setRequestHeader("Accept", s.dataType && s.accepts[s.dataType] ?
				s.accepts[s.dataType] + ", */*" :
				s.accepts._default);
        } catch (e) { }

        // Allow custom headers/mimetypes and early abort
        if (s.beforeSend && s.beforeSend.call(callbackContext, xhr, s) === false) {
            // Handle the global AJAX counter
            // if (s.global && ! --jQuery.active) {
            //    jQuery.event.trigger("ajaxStop");
            // }

            // close opended socket
            xhr.abort();
            return false;
        }

        //if (s.global) {
        //    trigger("ajaxSend", [xhr, s]);
        //}

        // Wait for a response to come back
        var onreadystatechange = xhr.onreadystatechange = function (isTimeout) {
            // The request was aborted
            if (!xhr || xhr.readyState === 0 || isTimeout === "abort") {
                // Opera doesn't call onreadystatechange before this point
                // so we simulate the call
                if (!requestDone) {
                    complete();
                }

                requestDone = true;
                if (xhr) {
                    xhr.onreadystatechange = h.noop;
                }

                // The transfer is complete and the data is available, or the request timed out
            } else if (!requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout")) {
                requestDone = true;
                xhr.onreadystatechange = h.noop;

                status = isTimeout === "timeout" ?
					"timeout" :
					!h.httpSuccess(xhr) ?
						"error" :
						s.ifModified && h.httpNotModified(xhr, s.url) ?
							"notmodified" :
							"success";

                var errMsg;

                if (status === "success") {
                    // Watch for, and catch, XML document parse errors
                    try {
                        // process the data (runs the xml through httpData regardless of callback)
                        data = h.httpData(xhr, s.dataType, s);
                    } catch (err) {
                        status = "parsererror";
                        errMsg = err;
                    }
                }

                // Make sure that the request was successful or notmodified
                if (status === "success" || status === "notmodified") {
                    // JSONP handles its own success callback
                    if (!jsonp) {
                        success();
                    }
                } else {
                    h.handleError(s, xhr, status, errMsg);
                }

                // Fire the complete handlers
                complete();

                if (isTimeout === "timeout") {
                    xhr.abort();
                }

                // Stop memory leaks
                if (s.async) {
                    xhr = null;
                }
            }
        };

        // Override the abort handler, if we can (IE doesn't allow it, but that's OK)
        // Opera doesn't fire onreadystatechange at all on abort
        try {
            var oldAbort = xhr.abort;
            xhr.abort = function () {
                if (xhr) {
                    oldAbort.call(xhr);
                }

                onreadystatechange("abort");
            };
        } catch (e) { }

        // Timeout checker
        if (s.async && s.timeout > 0) {
            setTimeout(function () {
                // Check to see if the request is still happening
                if (xhr && !requestDone) {
                    onreadystatechange("timeout");
                }
            }, s.timeout);
        }

        // Send the data
        try {
            xhr.send(type === "POST" || type === "PUT" || type === "DELETE" ? s.data : null);
        } catch (e) {
            h.handleError(s, xhr, null, e);
            // Fire the complete handlers
            complete();
        }

        // firefox 1.5 doesn't fire statechange for sync requests
        if (!s.async) {
            onreadystatechange();
        }

        function success() {
            // If a local callback was specified, fire it and pass it the data
            if (s.success) {
                s.success.call(callbackContext, data, status, xhr);
            }

            // Fire the global callback
            //if (s.global) {
            //    trigger("ajaxSuccess", [xhr, s]);
            //}
        }

        function complete() {
            // Process result
            if (s.complete) {
                s.complete.call(callbackContext, xhr, status);
            }

            // The request was completed
            //if (s.global) {
            //   trigger("ajaxComplete", [xhr, s]);
            //}

            // Handle the global AJAX counter
            //if (s.global && ! --jQuery.active) {
            //   jQuery.event.trigger("ajaxStop");
            //}
        }

        //function trigger(type, args) {
        //    (s.context ? jQuery(s.context) : jQuery.event).trigger(type, args);
        //}

        // return XMLHttpRequest to allow aborting the request etc.
        return xhr;
    };
    h.ajax.get=function( url, data, callback, type ) {
		// shift arguments if data argument was omited
		if ( h.isFunction( data ) ) {
			type = type || callback;
			callback = data;
			data = null;
		}

		return h.ajax({
			type: "GET",
			url: url,
			data: data,
			success: callback,
			dataType: type
		});
	};
    h.ajax.getScript=function( url, callback ) {
		return h.ajax.get(url, null, callback, "script");
	};
    h.ajax.loadScript=function(url,callback)
    {
        var loadscript = d.getElementById("hdomext_js_"+url);
        if(loadscript == null || loadscript == undefined)
        {
            var script = d.createElement("script");
            script.type = "text/javascript";
            script.id="hdomext_js_"+url;
            if(script.readyState)
            {
                script.onreadystatechange = function(){
                    if(script.readyState == "loaded" || script.readyState== "complete")
                    {
                        script.onreadystatechange=null;
                        if(callback != null)
                            callback();
                    }
                };
            }
            else
            {
                script.onload=function(){
                        if(callback != null)
                            callback();
                };
            }
            script.src=url;
            g("head")[0].appendChild(script);
       }
       else
       {
            if(callback != null)
                callback();
       }
    };
    h.ajax.loadCss=function(id,url,callback)
    {
        var link = d.getElementById(id);
        var isExit = true;
        if(link == null || link == undefined)
        {
            isExit = false;
        }
        if(!isExit)
            link = d.createElement("link");
        link.rel = 'stylesheet';
        link.type = 'text/css';
        link.id=id;
        if(link.readyState)
        {
            link.onreadystatechange = function(){
                if(link.readyState == "loaded" || link.readyState== "complete")
                {
                    link.onreadystatechange=null;
                    if(callback != null)
                        callback();
                }
            };
        }
        else
        {
            link.onload=function(){
                    if(callback != null)
                        callback();
            };
        }
        link.href=url;
        if(!isExit)
            g("head")[0].appendChild(link);
    };
	h.ajax.getJSON=function( url, data, callback ) {
		return h.ajax.get(url, data, callback, "json");
	};
    h.ajax.getJSONP = function(url,data,callback){
        return h.ajax.get(url, data, callback, "jsonp");
    };
	h.ajax.post=function( url, data, callback, type ) {
		// shift arguments if data argument was omited
		if ( h.isFunction( data ) ) {
			type = type || callback;
			callback = data;
			data = {};
		}
        if(type == null || type == undefined)
            type="html";
		return h.ajax({
			type: "POST",
			url: url,
			data: data,
			success: callback,
			dataType: type
		});
	};
    //#endregion ajax
    //#region 定义本地存储对象 h.Store
    h.Store = {};
    // escape spaces in name
    h.StoreSetting={
        name:"hdomext_Store_Database",
        domain:location.hostname || 'localhost.localdomain',
        flashpath:"persist.swf",
        expires : 365 * 2,
        path : '/',
        // sql for db backends (gears and db)
        sql: {
            version: '1', // db schema version
            create: "CREATE TABLE IF NOT EXISTS persist_data (k TEXT UNIQUE NOT NULL PRIMARY KEY, v TEXT NOT NULL)",
            get: "SELECT v FROM persist_data WHERE k = ?",
            set: "INSERT INTO persist_data(k, v) VALUES (?, ?)",
            remove: "DELETE FROM persist_data WHERE k = ?"
        },
        // default flash configuration
        flash: {
            // ID of wrapper element
            div_id: '_persist_flash_wrap',
            // id of flash object/embed
            id: '_persist_flash',
            size: { w: 1, h: 1 },
            // arguments passed to flash object
            args: {
                autostart: true
            }
        }
    };
    var stores = stores || {};  
     // (5 meg limit, src: http://ejohn.org/blog/dom-storage-answers/)
    stores["globalstorage"]={
            type:"globalstorage",
            size: 5 * 1024 * 1024,
            test: function () {
                return window.globalStorage ? true : false;
            },
            store : null,
            init: function () {
                stores["globalstorage"].store = globalStorage[h.StoreSetting.domain];
            },
            get: function (key) {
                 return stores["globalstorage"].store.getItem(key);
            },
            set: function (key, val) {
                stores["globalstorage"].store.setItem(key, val);
                return true;
            },
            remove: function (key) {
                    try{stores["globalstorage"].store.removeItem(key);}catch(e){}
                    return true;
            }
       };
       // localstorage backend (globalStorage, FF2+, IE8+)
        // (src: http://www.whatwg.org/specs/web-apps/current-work/#the-localstorage)
    stores["localstorage"]={
            // (unknown?)
            type:"localstorage",
            size: -1,
            store:null,
            test: function () {
                try
                {
                    return window.localStorage ? true : false;
                }
                catch(e)
                {
                    return false;
                }
            },
            init: function (storeSteup) {
                stores["localstorage"].store = localStorage;
            },
            get: function (key) {
                return stores["localstorage"].store.getItem(escape(key));
            },
            set: function (key, val) {
                stores["localstorage"].store.setItem(escape(key), val);
                return true;
            },
            remove: function (key) {
                // delete value
                try{ stores["localstorage"].store.removeItem(escape(key));}catch(e){}
               
                return true;
            }
        };

    // whatwg db backend (webkit, Safari 3.1+)
    // (src: whatwg and http://webkit.org/misc/DatabaseExample.html)
    stores["whatwg_db"] = {
        type: "whatwg_db",
        size: 200 * 1024,
        db: null,
        db_created: null,
        test: function () {
            var s = h.StoreSetting;
            var desc = s.name;
            if (!window.openDatabase)
                return false;
            if (!window.openDatabase(s.name, s.sql.version, desc, stores["whatwg_db"].size))
                return false;
            return true;
        },
        transaction: function (fn) {
            if (!stores["whatwg_db"].db_created) {
                var sql = h.StoreSetting.sql.create;
                stores["whatwg_db"].db.transaction(function (t) {
                    // create table
                    t.executeSql(sql, [], function () {
                        stores["whatwg_db"].db_created = true;
                    });
                }, empty); // trap exception
            }
            stores["whatwg_db"].db.transaction(fn);
        },
        init: function (storeSteup) {
            var s = h.StoreSetting;
            var desc = "Persistent storage for " + s.name; // init description and size
            stores["whatwg_db"].db = openDatabase(s.name, s.sql.version, desc, stores["whatwg_db"].size);    // create database handle
        },
        get: function (key) {
            var sql = h.StoreSetting.sql.get;
            // begin transaction
            stores["whatwg_db"].transaction(function (t) {
                var rh = null;
                t.executeSql(sql, [key], function (t, r) {
                    if (r.rows.length > 0)
                        rh = r.rows.item(0)['v'];
                });
                return rh;
            });
        },

        set: function (key, val) {
            var rm_sql = h.StoreSetting.sql.remove, sql = h.StoreSetting.sql.set;
            // begin set transaction
            stores["whatwg_db"].transaction(function (t) {
                // exec remove query
                t.executeSql(rm_sql, [key], function () {
                    // exec set query
                    t.executeSql(sql, [key, val], function (t, r) {
                    });
                });
            });
        },
        // begin remove transaction
        remove: function (key, fn, scope) {
            var sql = h.StoreSetting.sql.remove;
            stores["whatwg_db"].transaction(function (t) {
                t.executeSql(sql, [key]);
            });
        }
    };
    // flash backend (requires flash 8 or newer)
    // http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_16194&sliceId=1
    // http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002200.html
    stores["flash"]={
            type:"flash",
            size:-1,
            el:null,
            test: function () {
                // TODO: better flash detection
                if (!window.SWFObject || !deconcept || !deconcept.SWFObjectUtil)
                    return false;

                // get the major version
                var major = deconcept.SWFObjectUtil.getPlayerVersion().major;

                // check flash version (require 8.0 or newer)
                return (major >= 8) ? true : false;
            },
            init: function () {
                if (!stores["flash"].el) 
                {
                    var o, key, el, cfg = h.StoreSetting.flash;

                    // create wrapper element
                    el = document.createElement('div');
                    el.id = cfg.div_id;

                    // FIXME: hide flash element
                    // el.style.display = 'none';

                    // append element to body
                    document.body.appendChild(el);

                    // create new swf object
                    o = new SWFObject(h.StoreSetting.flashpath, cfg.id, cfg.size.w, cfg.size.h, '8');

                    // set parameters
                    for (key in cfg.args)
                        o.addVariable(key, cfg.args[key]);

                    // write flash object
                    o.write(el);

                    // save flash element
                    stores["flash"].el = document.getElementById(cfg.id);
                  }
                },
                get: function (key) {
                    key = escape(key);   // escape key
                   return stores["flash"].el.get(h.StoreSetting.name, key);   // get value
                },
                set: function (key, val) {
                    var old_val;
                    // escape key
                    key = escape(key);
                    // set value
                    old_val = stores["flash"].el.set(h.StoreSetting.name, key, val);
                    return true;
                },
                remove: function (key, fn, scope) {
                    var val;
                    key =escape(key);     // get key
                    stores["flash"].el.remove(h.StoreSetting.name, key);  // remove old value
                    return true;
                }
        };
    //同一端口、同一服务器、同一目录下
    stores["ie"]={
            prefix: h.StoreSetting.name,
            // style:    'display:none; behavior:url(#default#userdata);',
            // 64k limit
            type:"ie",
            size: 64 * 1024,
            el:null,
            test: function () {
                // make sure we're dealing with IE
                // (src: http://javariet.dk/shared/browser_dom.htm)
                return window.ActiveXObject ? true : false;
            },
            make_userdata: function (id) {
                var el = document.createElement('div');
                // set element properties
                el.id = id;
                el.style.display = 'none';
                el.addBehavior('#default#userData');
                var oTimeNow = new Date(); // Start Time
                oTimeNow.setMinutes(oTimeNow.getMinutes() +  h.StoreSetting.expires);
               var sExpirationDate = oTimeNow.toUTCString();
                el.expires=sExpirationDate;
                // append element to body
                document.body.appendChild(el);
                // return element
                return el;
            },
            load: function () {
                //alert("load_"+h.StoreSetting.name);
                stores["ie"].el.load(escape(h.StoreSetting.name));
            },
            save: function () {
                //alert("save_"+h.StoreSetting.name);
                stores["ie"].el.save(escape(h.StoreSetting.name));
            },
            init: function (storeSteup) {
                    var id = "div_"+h.StoreSetting.name;
                    stores["ie"].el = stores["ie"].make_userdata(id);
            },
            get: function (key) {
                stores["ie"].load(); // load data
                //alert("get_"+key+"="+stores["ie"].el.getAttribute(key));    
                return stores["ie"].el.getAttribute(escape(key));  // get value
            },
            set: function (key, val) {
                stores["ie"].el.setAttribute(escape(key), val);  // set attribute
                stores["ie"].save();// save data
                //alert("set_"+key+"="+val);
                return true;
            },
            remove:function(key){
                try{ 
                   stores["ie"].el.removeAttribute(key);
                   stores["ie"].el.save();
               }catch(e){}
            }
        };

    
    h.Store.init=function (setupobj) {
        if(setupobj!=null)
             h.extend(true,h.StoreSetting, setupobj);
        // loop over all backends and test for each one
        if(h.Store.isInit != true)
        {
            for(var o in stores) {
                b = stores[o];
                // test for backend
                if (b.test()) {
                    // found backend, save type and size
                     h.Store=stores[o];
                     h.Store.init();
                     h.Store.isInit = true;
                     return true;
                }
            }
        }
    };
    //#endregion  定义本地存储对象 h.Store
    //线性动画，支持 "0,250,px" (从0到250) 和 "+500,px", (从当前值 +500)
    //#region Animate Control
    h.Animate = h.Animate || {};
    h.Animate.CreateContexts=function(objs,duration,animateType){
        var rese = /^([-]{0,1}[0-9]+),([-]{0,1}[0-9]+)$/i;
        //var resp = /^([+|-]{1}[0-9]+),(px|%){1}$/i,
        var contexts = {};
        var eo = objs;
        for(var i in eo)
        {
            var resem  = eo[i].match(rese);
            if(resem)
            {
                contexts[i]={name:i,value:eo[i]};
                contexts[i].start = parseInt(resem[1]);
                contexts[i].end = parseInt(resem[2]);
                contexts[i].len = contexts[i].end-contexts[i].start;
                contexts[i].state =  h.Animate.State.Ready;
                contexts[i].fun = animateType;
                contexts[i].direction = contexts[i].len >0 ? 1 : -1;
                contexts[i].len = contexts[i].len*contexts[i].direction;
                contexts[i].duration = duration;
                contexts[i].currentStep = 0;
                contexts[i].GetValue=function(){
                    var value = 0;
                    if(this.currentStep<this.duration){
		                this.currentStep++;
			            value = this.start+Math.ceil(this.fun(this.currentStep,0,this.len,this.duration))*this.direction;
		            }else{
			            value =this.end;
                        this.state= h.Animate.State.Completed;
		            }
                    return value;
                };
            }
        }
        return contexts;
    };
    h.Animate.InitElement=function(el,objs,animateType,duration,completeHandle,stepHandle)
    {
        el.Animation=el.Animation||{};
        el.Animation.Contexts = h.Animate.CreateContexts(objs,duration,animateType);
        el.Animation._run=function(){
            el.style.overflow="hidden";
            var elStyle = el.style;
            var Contexts = el.Animation.Contexts;
            for(var i in Contexts)
            {
                elStyle[i] = Contexts[i].GetValue()+"px";
            }
            if(stepHandle != null)
                stepHandle(el);
            if(el.Animation.RunIntervalHandler !=undefined && el.Animation.IsCompleted())
            {
                clearInterval(el.Animation.RunIntervalHandler);
                el.Animation.RunIntervalHandler = undefined;
                if(completeHandle != null)
                {
                    el.style.overflow="inherit";
                    completeHandle(el);
                }
            }
        };
        el.Animation.IsCompleted =function(){
            var Contexts = el.Animation.Contexts;
            for(var i in Contexts)
            {
                if(Contexts[i].state != h.Animate.State.Completed)
                    return false;
            }
            return true;
        };  
        el.Animation.Run=function(){
            if(el.Animation.RunIntervalHandler == undefined)
                el.Animation.RunIntervalHandler = setInterval(el.Animation._run,10);
        };
    };
    h.Animate.State={Ready:0,Start:1,Stop:2,Completed:3};
    h.Animate.Tween = {
	    Linear: function(t,b,c,d){ return c*t/d + b; },
	    Quad: {
		    easeIn: function(t,b,c,d){
			    return c*(t/=d)*t + b;
		    },
		    easeOut: function(t,b,c,d){
			    return -c *(t/=d)*(t-2) + b;
		    },
		    easeInOut: function(t,b,c,d){
			    if ((t/=d/2) < 1) return c/2*t*t + b;
			    return -c/2 * ((--t)*(t-2) - 1) + b;
		    }
	    },
	    Cubic: {
		    easeIn: function(t,b,c,d){
			    return c*(t/=d)*t*t + b;
		    },
		    easeOut: function(t,b,c,d){
			    return c*((t=t/d-1)*t*t + 1) + b;
		    },
		    easeInOut: function(t,b,c,d){
			    if ((t/=d/2) < 1) return c/2*t*t*t + b;
			    return c/2*((t-=2)*t*t + 2) + b;
		    }
	    },
	    Quart: {
		    easeIn: function(t,b,c,d){
			    return c*(t/=d)*t*t*t + b;
		    },
		    easeOut: function(t,b,c,d){
			    return -c * ((t=t/d-1)*t*t*t - 1) + b;
		    },
		    easeInOut: function(t,b,c,d){
			    if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
			    return -c/2 * ((t-=2)*t*t*t - 2) + b;
		    }
	    },
	    Quint: {
		    easeIn: function(t,b,c,d){
			    return c*(t/=d)*t*t*t*t + b;
		    },
		    easeOut: function(t,b,c,d){
			    return c*((t=t/d-1)*t*t*t*t + 1) + b;
		    },
		    easeInOut: function(t,b,c,d){
			    if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
			    return c/2*((t-=2)*t*t*t*t + 2) + b;
		    }
	    },
	    Sine: {
		    easeIn: function(t,b,c,d){
			    return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
		    },
		    easeOut: function(t,b,c,d){
			    return c * Math.sin(t/d * (Math.PI/2)) + b;
		    },
		    easeInOut: function(t,b,c,d){
			    return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
		    }
	    },
	    Expo: {
		    easeIn: function(t,b,c,d){
			    return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
		    },
		    easeOut: function(t,b,c,d){
			    return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
		    },
		    easeInOut: function(t,b,c,d){
			    if (t==0) return b;
			    if (t==d) return b+c;
			    if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
			    return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
		    }
	    },
	    Circ: {
		    easeIn: function(t,b,c,d){
			    return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
		    },
		    easeOut: function(t,b,c,d){
			    return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
		    },
		    easeInOut: function(t,b,c,d){
			    if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
			    return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
		    }
	    },
	    Elastic: {
		    easeIn: function(t,b,c,d,a,p){
			    if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
			    if (!a || a < Math.abs(c)) { a=c; var s=p/4; }
			    else var s = p/(2*Math.PI) * Math.asin (c/a);
			    return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
		    },
		    easeOut: function(t,b,c,d,a,p){
			    if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
			    if (!a || a < Math.abs(c)) { a=c; var s=p/4; }
			    else var s = p/(2*Math.PI) * Math.asin (c/a);
			    return (a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b);
		    },
		    easeInOut: function(t,b,c,d,a,p){
			    if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
			    if (!a || a < Math.abs(c)) { a=c; var s=p/4; }
			    else var s = p/(2*Math.PI) * Math.asin (c/a);
			    if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
			    return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
		    }
	    },
	    Back: {
		    easeIn: function(t,b,c,d,s){
			    if (s == undefined) s = 1.70158;
			    return c*(t/=d)*t*((s+1)*t - s) + b;
		    },
		    easeOut: function(t,b,c,d,s){
			    if (s == undefined) s = 1.70158;
			    return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
		    },
		    easeInOut: function(t,b,c,d,s){
			    if (s == undefined) s = 1.70158; 
			    if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
			    return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
		    }
	    },
	    Bounce: {
		    easeIn: function(t,b,c,d){
			    return c - h.Animate.Tween.Bounce.easeOut(d-t, 0, c, d) + b;
		    },
		    easeOut: function(t,b,c,d){
			    if ((t/=d) < (1/2.75)) {
				    return c*(7.5625*t*t) + b;
			    } else if (t < (2/2.75)) {
				    return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
			    } else if (t < (2.5/2.75)) {
				    return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
			    } else {
				    return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
			    }
		    },
		    easeInOut: function(t,b,c,d){
			    if (t < d/2) return h.Animate.Tween.Bounce.easeIn(t*2, 0, c, d) * .5 + b;
			    else return h.Animate.Tween.Bounce.easeOut(t*2-d, 0, c, d) * .5 + c*.5 + b;
		    }
	    }
    };
    //#endregion Animate Control
    h.Timer = h.Timer || {
        _data:{},
        start:function(key){
            h.Timer._data[key] = +new Date();
        },
        stop:function(key){
            var time =  h.Timer._data[key];
            if(time){
                h.Timer._data[key]=+new Date()-time;
            }
        },
        getTime:function(key){
            return  h.Timer._data[key];
        },
        Rmove:function(key)
        {
            delete h.Timer._data[key];
        }
    };
    //#endregion hyJsFramework function
    //#region Definition dom UI  Control Class
    h.Defui = h.Defui || {};
    h.InitDom = function (context) {
        h.InitCustomTags(context);
    };
    h.ReInitDom = function (context) {
        for (var key in h.Defui) {
            context = context == undefined ? d.body : context;
            var objs = g(key, context);
            objs.each(function (i, args) {
                try { h.Defui[key].Init(this); } catch (e) { alert("error:" + e); return; }
            });
        }
    };
    //key frameWork------------------------------------------------------------------------
    h.key = h.key || {};
    h.key.Group= new Array();
    h.key.CurrentGroup = "default";
    h.key.PreGroup = "default";
    h.key.Group["default"] =new Array();
    h.key.GetKeyCode = function(evt){
        return evt.keyCode?evt.keyCode:evt.which; 
    };
    h.key.Addkey = function(groupName,keyName,fn)
    {
        if(h.key.Group[groupName] == null)
        {
            h.key.Group[groupName] = new Array();
        }
        var keys = keyName.split("+");
        var kshift = 0,kctrl=0,kalt=0,kchar=-1;
        for(var i=0,j=keys.length;i<j;i++)
        {
          var tkey = keys[i].toUpperCase();
          switch (tkey) {
                case "CTRL":
                    kctrl=1;
                    break;
                case "SHIFT":
                    kshift=1;
                    break;
                case "ALT":
                    kalt=1;
                    break;
                default:
                    kchar = h.key.map[tkey];
                    break;
            }
        }
        keyName = kshift.toString()+kctrl.toString()+kalt.toString()+kchar.toString();
        h.key.Group[groupName][keyName] = h.key.Group[groupName][keyName] || {};
        h.key.Group[groupName][keyName].keyfn = fn;
        h.key.Group[groupName][keyName].isRuning = false;

    };
    h.key.map={
    A:65,J:74,S:83,1:49,B:66,K:75,T:84,2:50,C:67,
    L:76,U:85,3:51,
    D:68,M:77,V:86,4:52,
    E:69,N:78,W:87,5:53,
    F:70,O:79,X:88,6:	54,
    G:71,P:80,Y:89,7:55,
    H:72,Q:81,Z:90,8:56,
    I:73,R:82,0:48,9:57,
    BACKSPACE:8,ESC:27,RIGHTARROW:39,	"-":189,
    TAB:9,SPACE:32,DOWNARROW:40,".":190,
    CLEAR:12,PAGEUP:33,INSERT:45,"/":191,
    ENTER:13	,PAGEDOWN:34,DELETE:46,"`":192,
    SHIFT:16,END:35,NUMLOCK:144,"[":219,
    CTRL:17,"HOME":36,";":186,"\\":220,
    ALT:18,LEFTARROW:37,"=":187,"]":221,CAPELOCK:20,UPARROW:38,",":188,"\'":222,
    Num_0:96,Num_8:104,	F1:112,F7:118,
    Num_1:97,Num_9:105,F2:113,F8:119,
    Num_2:98,"Num_*":106,F3:114,F9:120,
    Num_3:99,"Num_ADD":107,F4:115,F10:121,
    Num_4:100,Num_Enter:108,F5:116,F11:122,
    Num_5:101,"Num_-":109,F6:117,F12:123,
    Num_6:102,"Num_.":110,
    Num_7:103,"Num_/":111
    };
    h.key.ActiveGroup= function(groupName)
    {
        if(groupName == null || groupName == undefined)
        {
            h.key.CurrentGroup = h.key.PreGroup;
            return h.key.CurrentGroup ;
        }
        if(h.key.CurrentGroup == groupName) return h.key.CurrentGroup;
        h.key.PreGroup=h.key.CurrentGroup;
        h.key.CurrentGroup=groupName;
        return h.key.CurrentGroup;
    };
    //end key framework------------------------------------------------------------------------
    //定义所有HTML标记扩展 >IE8 firefox google，IE6/IE7 时，只有通过_g("Id")才能扩展标记
    h.InitExtend = function () {
        if (window.Element) {       // 检查是否拥有 constructor.prototype模型。
            h.Extend(window.Element.prototype, h.Defui["default"]); //定义所有HTML标记的扩展
        }
    };
    //初始化自定义的HTML TAG
    h.InitCustomTags = function (context) {
        //初始化自定义HTML标记的。
        for (var key in h.Defui) {
            context = context == undefined ? d.body : context;
            var objs = g(key, context);
            objs.each(function (i, args) {
                try { if (this.isInit == undefined) h.Defui[key].Init(this); } catch (e) { alert("error:" + e); return; }
            });
        }
    };
    h.Extend = function (o, classFn) {
        if (!o) return;
       if (!o.isDefindefault) { o = h.extend(true, o, classFn); } //ie 7 扩展失效
       //o = h.extend(true, o, classFn);
        return o;
    };
    h.DefinCollectionFnExtend = function (o, classFn) {
        if (!o) return;
        if (!o.isDefinCollectionFn) o = h.extend(true, o, classFn); //ie 7 扩展失效
        //o = h.extend(true, o, classFn);
        return o;
    };
    h.IsNull = function (obj)
    {
        if (obj == null || obj == undefined || obj == NaN)
            return true;
        return false;
    };
    //执行选择器时添加属性。
    h.Defui.CallTagCheck = function (e, tagType, funName) {
        if (!e) return;
        if (h.GetTagName(e) !== tagType) {
            var errorMsg = "error: " + tagType + "." + funName + " this element is not " + tagType + " this Tags = " + h.GetTagName(e);
            alert(errorMsg);
            throw errorMsg;
        }
    };
    h.Defui["default"] = {
        isDefindefault: true,
        html: function (value) {
            if (value == null || value == undefined)
                return this.innerHTML;
            this.innerHTML = value;
            h.ReInitDom(this);
        },
        AppendHtml: function (value) {
            if (value == undefined)
                return this.innerHTML;
            this.innerHTML = this.innerHTML + value;
            h.ReInitDom(this);
        },
        AddEvent: function (eventName, fn, useCapture) {
            h.addEvent(this, eventName, fn, useCapture);
        },
        DeleteEvent: function (eventName, fn, useCapture) {
            h.deleteEvent(this, eventName, fn, useCapture);
        },
        Animate:function(objs,animateType,duration,completeHandle,stepHandle){
     
            h.Animate.InitElement(this,objs,animateType,duration,completeHandle,stepHandle);
            this.Animation.Run();
        }
    };
    h.Default=h.Defui["default"];
    h.Default.DomCollectionFn = {
        isDefinCollectionFn: true,
        first: function () {
            return this[0];
        },
        last: function () {
            return this[this.length];
        },
        //此方法不能加入HTML代码？
        each: function (fn, args) {
            var obj, i = 0;
            while (obj = this[i++]) {
                fn.call(obj, i, args);
            }
        },
        AddEvent: function (eventName, fn, useCapture) {
            var obj, i = 0;
            while (obj = this[i++]) {
                h.addEvent(obj, eventName, fn, useCapture);
            }
        },
        DeleteEvent: function (eventName, fn, useCapture) {
            var obj, i = 0;
            while (obj = this[i++]) {
                h.deleteEvent(obj, eventName, fn, useCapture);
            }
        }
    };
   
    //#region 控件模板标签
    h.Defui["h:itemtemplet"] = h.Defui["h:itemtemplet"] || {}; h.ItemTemplet = h.Defui["h:itemtemplet"];
    h.ItemTemplet.Init = function (e) {
        e.isInit = true;
    };
    //#endregion 控件模板标签
    //#region h:btn 控件
    h.Defui["h:btn"] = h.Defui["h:btn"] || {}; h.Btn = h.Defui["h:btn"];
    h.Btn.Init = function (obj) {
        h.Defui.CallTagCheck(obj, "h:btn", "Init");
        obj.typename = h.GetTagName(obj);
        obj.css = h.Attr(obj, "css") ? h.Attr(obj, "css") : "";
        obj.csshover = h.Attr(obj, "csshover") ? h.Attr(obj, "csshover") : "hover";
        obj.cssactive = h.Attr(obj, "cssactive") ? h.Attr(obj, "cssactive") : "active";
        obj.cssactivehover = h.Attr(obj, "cssactivehover") ? h.Attr(obj, "cssactivehover") : "active_hover";
        obj.isactive = h.Attr(obj, "isactive") ? h.Attr(obj, "isactive") : "false";
        obj.keyevent = h.Attr(obj, "keyevent") ? h.Attr(obj, "keyevent") : "click";
        obj.keygroup = h.Attr(obj, "keygroup") ? h.Attr(obj, "keygroup") : "default";
        obj.keychar = h.Attr(obj, "keychar") ? h.Attr(obj, "keychar") : "Ctrl+NUMLOCK";
        obj.csstemp = "";
        obj.MouseOverHandler=null;
        obj.MouseOutHandler=null;
        h.addEvent(obj, "mouseout", h.Btn.OnMouseOut(obj), false);
        h.addEvent(obj, "mouseover", h.Btn.OnMouseOver(obj), false);
        if (obj.isactive == "true")
            obj.className = obj.cssactive;
        else
            obj.className = obj.css;
        //#region 方法
        obj.Active=function(isactive){
            h.Defui.CallTagCheck(this, "h:btn", "Active");
            this.isactive = isactive;
            if (isactive === "true") {
                this.tempcss = this.cssactive;
                this.className = this.cssactive;
            }
            else {
                this.tempcss = this.css;
                this.className = this.css;
            }
        };
        //#endregion 方法
        obj.isInit = true;
    };
    h.Btn.OnMouseOver = function (obj) {
        return function () {
            //var o = h.GetEventArg(h.GetEvent());
            var o = obj;
            h.Defui.CallTagCheck(o, "h:btn", "OnMouseOver");
            if (o.isactive === "true") {
                o.tempcss = o.cssactive;
                o.className = o.cssactivehover;
            }
            else {
                o.tempcss = o.css;
                o.className = o.csshover;
            }
            if(o.MouseOverHandler!=null)
                o.MouseOverHandler(o);
        };
    };
    h.Btn.OnMouseOut = function (obj) {
        return function () {
            var o = obj;
            h.Defui.CallTagCheck(o, "h:btn", "OnMouseOut");
            if (o.isactive === "true")
                o.className = o.tempcss;
            else
                o.className = o.tempcss;
            if(o.MouseOutHandler != null)
                o.MouseOutHandler(o);
        };
    };
//    h.Btn.Active = function (obj, isactive) {
//        h.Defui.CallTagCheck(obj, "h:btn", "Active");
//        obj.isactive = isactive;
//        if (isactive === "true") {
//            obj.tempcss = obj.cssactive;
//            obj.className = obj.cssactive;
//        }
//        else {
//            obj.tempcss = obj.css;
//            obj.className = obj.css;
//        }
//    };
    //#endregion h:btn 
    //#region h:text
    h.Defui["h:text"] = h.Defui["h:text"] || {}; h.Text = h.Defui["h:text"];
    h.Text.Init = function (e) {
        e.isInit = true;
        e.text = h.Attr(e, "text") ? h.Attr(e, "text") : "";
        e.isreadonly = h.Attr(e, "isreadonly") ? h.Attr(e, "isreadonly") : "readonly";
        e.istextarea = h.Attr(e, "istextarea") ? h.Attr(e, "istextarea") : "false";
        e.maxchar = h.Attr(e, "maxchar") ? h.Attr(e, "maxchar") : "1000000";
        e.ispsd=h.Attr(e,"ispsd")?h.Attr(e,"ispsd"):"false";
     
        e.maxchar = parseInt(e.maxchar);
        e.KeyUpHandle = null;
        var readonly = e.isreadonly == "readonly" ? "" : "readonly";
        e.inputId = e.id + "text";
        var html = new h.StringBuilder();
        if (e.istextarea === "false")
        { 
            if(e.ispsd === "false")
                html.Add(["<input type='text' value='" , e.text , "' " , readonly , "/>"]);
            else
                html.Add(["<input type='password' value='" , e.text , "' " , readonly , "/>"]);
        }
        else
            html.Add(["<textarea " , readonly , ">" , e.text , "</textarea>"]);
        e.innerHTML = html.ToString();
        if (e.istextarea === "false")
            e.txt = g("input", e)[0];
        else
            e.txt = g("textarea", e)[0];
        h.addEvent(e.txt, "keyup", h.Text.OnKeyUp(e));
        //#region 方法
        e.SetHeight = function (height) {
            this.style.height = height + "px";
            this.txt.style.height = height + "px";
        };
        e.GetHeight = function () {
            return this.style.height;
        };
        e.SetWidth = function (width) {
            this.style.width = width + "px";
            this.txt.style.width = this.style.width;
        };
        e.GetWidth = function () {
            return this.style.width;
        };
        e.GetText = function(){
             return this.txt.value;
        };
        e.SetText = function(value){
             this.txt.value = value;
        };
        //#endregion 方法
    };
    h.Text.GetText = function (e) {
        return e.txt.value;
    };
    h.Text.SetText = function (e, value) {
        e.txt.value = value;
    };
    h.Text.AddEvent = function (e, eventname, fn) {
        h.addEvent(e.txt, eventname, fn, false);
    };
    h.Text.DeleteEvent = function (e, eventName, fn) {
        h.addEvent(e.txt, eventName, fn, false);
    };
    h.Text.OnKeyUp = function (e) {
        return function () {
            var value = e.GetText(e);
            if (value.length > e.maxchar) {
                value = value.substr(0, e.maxchar);
                e.SetText(value);
            }
            if (e.KeyUpHandle != null)
                e.KeyUpHandle(e, value.length);
        };
    };
    //#endregion h:text
    //#region h:layout 
    var GetObjIndexbyLayoutType = function (name, objs) {
        for (var i = 0; i < objs.length; i++) {
            if (h.GetTagName(objs[i]) == name)
                return objs[i];
        }
        return null;
    };
    //将属性为 "0,2,3,4" 转为对象。
 
    var Position = function (e, str) {
        this.e = e; this.top = 0; this.left = 0; this.width = 0; this.height = 0;
        this.covert = function (str) {
            var s = str.split(",");
            this.top = parseInt(s[0]); this.left = parseInt(s[1]); this.width = (s[2]); this.height = (s[3]);
        };
        this.uncovert = function () {
            return this.top + "," + this.left + "," + this.width + "," + this.height;
        };
        this.Bind = function () {
            try {
                this.e.style.top = this.top + "px";
                this.e.style.left = this.left + "px";
                this.e.style.width = this.width + "px";
                this.e.style.height = this.height + "px";
            } catch (e) { };
        };
        this.UnBind = function () {
            this.top = isNaN(parseInt(this.e.style.top)) ? 0 : parseInt(this.e.style.top);
            this.left = isNaN(parseInt(this.e.style.left)) ? 0 : parseInt(this.e.style.left);
            this.width = isNaN(parseInt(this.e.style.width)) ? 0 : parseInt(this.e.style.width);
            this.height = isNaN(parseInt(this.e.style.height)) ? 0 : parseInt(this.e.style.height);
        };
        this.covert(str);
    };
    h.Position = Position;
    //将属性为 "0,2,3,4" 转为对象。
    var Border = function (e, str) {
        this.e = e; this.top = 1; this.right = 1; this.bottom = 1; this.left = 1;
        this.convert = function (str) {
            var s = str.split(",");
            this.top = parseInt(s[0]); this.right = parseInt(s[1]); this.bottom = parseInt(s[2]); this.left = parseInt(s[3]);
        };
        this.Bind = function () {
            if(this.e == null || this.e == undefined) return;
                this.e.style.borderTopWidth = this.top + "px";
                this.e.style.borderRightWidth = this.right + "px";
                this.e.style.borderBottomWidth = this.bottom + "px";
                this.e.style.borderLeftWidth = this.left + "px";
        };
        this.UnBind = function () {
            if(this.e == null || this.e == undefined) return;
            this.top = isNaN(parseInt(this.e.style.borderTopWidth)) ? 1 : parseInt(this.e.style.borderTopWidth);
            this.right = isNaN(parseInt(this.e.style.borderRightWidth)) ? 1 : parseInt(this.e.style.borderRightWidth);
            this.bottom = isNaN(parseInt(this.e.style.borderBottomWidth)) ? 1 : parseInt(this.e.style.borderBottomWidth);
            this.left = isNaN(parseInt(this.e.style.borderLeftWidth)) ? 1 : parseInt(this.e.style.borderLeftWidth);
        }
        this.convert(str);
    }
    h.Border = Border;
    h.Defui["h:layout"] = {}; h.layout = h.Defui["h:layout"];
    h.layout.LayoutWhileFun = function () {
        g("h:layout")[0].DoLayout();
    };
    h.layout.Init = function (e) {
        h.Defui.CallTagCheck(e, "h:layout", "Init");
        e.isInit = true;
        e.pelem = e.parentNode;
        e.typename = h.GetTagName(e);
        e.hposition = new Position(e, (h.Attr(e, "hposition") ? h.Attr(e, "hposition") : "0,0,*,*"));
        e.borderwidth = new Border(e, (h.Attr(e, "borderwidth") ? h.Attr(e, "borderwidth") : "0,0,0,0"));
        e.minwidth = h.Attr(e, "minwidth") ? h.Attr(e, "minwidth") : "0";
        e.minheight = h.Attr(e, "minheight") ? h.Attr(e, "minheight") : "0";
        e.aTop = null;
        e.aLeft = null;
        e.style.visibility = "visible";
        e.DoLayoutedHandler=null; //function(e){};
        //#region 方法
        e.DoLayout = function () {
            h.Defui.CallTagCheck(e, "h:layout", "DoLayout");
            var p = {}, b = {};
            p = h.extend(true, p, e.hposition), b = h.extend(true, b, e.borderwidth);
            var pvborder = b.right + b.left, phborder = b.top + b.bottom;
            if (e.pelem.tagName === "BODY") {
                var pageSize = h.GetPageSize();
                p.top = p.top === "*" ? 0 : p.top;

                p.left = p.left === "*" ? 0 : p.left;
                e.aTop = 0;
                e.aLeft = 0;
                p.width = p.width === "*" ? pageSize.ww - b.right - b.left : p.width;
                p.height = p.height === "*" ? pageSize.wh - b.top - b.bottom : p.height;
                
            }
            else {
                p.top = p.top;
                p.left = p.left;
                e.aTop = e.pelem.aTop;
                e.aLeft = e.pelem.aLeft;
                p.width = p.width === "*" ? parseInt(e.pelem.style.width) - pvborder : p.width;
                p.height = p.height === "*" ? parseInt(e.pelem.style.height) - phborder : p.height;
            }
            if (p.width < e.minwidth) { p.width = e.minwidth; e.pelem.style.overflowX = "auto"; } else { e.pelem.style.overflowX = "hidden"; }
            if (p.height < e.minheight) { p.height = e.minheight; e.pelem.style.overflowY = "auto"; } else { e.pelem.style.overflowY = "hidden"; }
            p.Bind(); b.Bind();
            var c = e.children;
            var childLayout = GetObjIndexbyLayoutType("h:layout", c);
            if (childLayout != null) {
               if(e.DoLayoutedHandler !=null && h.isFunction(e.DoLayoutedHandler))
                    e.DoLayoutedHandler(e);
                childLayout.pelem = e;
                childLayout.DoLayout(childLayout);
                return;
            }
            if (c.length == 0 || c.length == 1 || c.length == 2 || c.length == 3) {
                var left = GetObjIndexbyLayoutType("h:left", c);
                var right = GetObjIndexbyLayoutType("h:right", c);
                var vsplit = GetObjIndexbyLayoutType("h:vsplitter", c);
                var head = GetObjIndexbyLayoutType("h:head", c);
                var bottom = GetObjIndexbyLayoutType("h:bottom", c);
                var hspliter = GetObjIndexbyLayoutType("h:hsplitter", c);
                if (c.length == 1) {
                    var oneLayout = null;
                    if (vsplit != null) { vsplit.style.display = "none"; return; }
                    if (hspliter != null) { hspliter.style.display = "none"; return; }
                    if (left != null) oneLayout = left;
                    if (right != null) oneLayout = right;
                    if (head != null) oneLayout = head;
                    if (bottom != null) oneLayout = bottom;
                    if (oneLayout == null) { alert("not find Layout control."); return; }
                    var op = {}, ob = {};
                    op = h.extend(true, op, oneLayout.hposition), ob = h.extend(true, ob, oneLayout.borderwidth);
                    if (op.width === "*") {
                        op.top = p.top;
                        op.left = p.left;
                        oneLayout.aTop = e.aTop;
                        oneLayout.aLeft = e.aLeft;
                        op.width = p.width - ob.left - ob.right;
                        op.height = p.height - ob.top - ob.bottom;
                        op.Bind();
                        ob.Bind();
                    }
                    else { h.error("error:h:layout`s Control hposition must be hposition ='0,0 ,*,*'; "); }
                    if(e.DoLayoutedHandler !=null && h.isFunction(e.DoLayoutedHandler))
                        e.DoLayoutedHandler(e);
                    return;
                }
                if (left != null && right != null) {
                    left.aTop = right.aTop = e.aTop;
                    left.aLeft = e.aLeft;
                    var lp = {}, lb = {}, rp = {}, rb = {};
                    lp = h.extend(true, lp, left.hposition);
                    lb = h.extend(true, lb, left.borderwidth);
                    rp = h.extend(true, rp, right.hposition);
                    rb = h.extend(true, rb, right.borderwidth);
                    var lvborder = lb.left + lb.right, lhborder = lb.top + lb.bottom, rvborder = rb.left + rb.right, rhborder = rb.top + rb.bottom;
                    if (vsplit == null) {
                        lp.top = p.top;
                        rp.top = p.top;
                        lp.height = p.height - lhborder;
                        rp.height = p.height - rhborder;
                        lp.left = p.left;
                        if (lp.width === "*" && rp.width === "*") {
                            lp.width = rp.width = (p.width - lvborder - rvborder) / 2;
                        } else if (lp.width === "*" && rp.width !== "*") {
                            lp.width = p.width - lvborder - rvborder - rp.width;
                        } else if (lp.width !== "*" && rp.width === "*") {
                            rp.width = p.width - lvborder - rvborder - lp.width;
                        } else if (lp.width !== "*" && rp.width !== "*") {
                            rp.left = parseInt(lp.width) + parseInt(lb.right) + parseInt(lb.left);
                        }
                        rp.left = parseInt(lp.width) + parseInt(lb.right) + parseInt(lb.left);
                        right.aLeft = e.aLeft + rp.left;
                        lp.Bind(); lb.Bind(); rp.Bind(); rb.Bind();
                    }
                    else {
                        var sp = {}, sb = {};
                        sp = h.extend(true, sp, vsplit.hposition);
                        sb = h.extend(true, sb, vsplit.borderwidth);
                        var shborder = sb.top + sb.bottom, svborder = sb.left + sb.right;
                        lp.top = p.top, rp.top = p.top, sp.top = p.top;
                        lp.height = p.height - lhborder;
                        rp.height = p.height - rhborder;
                        sp.height = p.height - shborder;
                        lp.left = p.left;
                        if (sp.width === "*") { h.error('error: layout vsplitter.hposition is like vsplitter.hposition=0,0,30,* '); return; }
                        if (lp.width === "*" && rp.width === "*") {
                            lp.width = rp.width = (p.width - lvborder - rvborder - sp.width - svborder) / 2;
                            vsplit.dragObj = { obj: left, layoutObj: e, type: "left" };
                        } else if (lp.width === "*" && rp.width !== "*") {
                            vsplit.dragObj = { obj: right, layoutObj: e, type: "right" };
                            if(lp.width !=0) if(lp.width < left.minwidth) lp.width = left.minwidth;
                            if(rp.width !=0) if(rp.width < right.minwidth) rp.width = right.minwidth;
                            lp.width = p.width - lvborder - rvborder - svborder - sp.width - rp.width;
                       
                        } else if (lp.width !== "*" && rp.width === "*") {
                            vsplit.dragObj = { obj: left, layoutObj: e, type: "left" };
                            if(lp.width !=0) if(lp.width < left.minwidth) lp.width = left.minwidth;
                            if(rp.width !=0) if(rp.width < right.minwidth) rp.width = right.minwidth;
                            rp.width = parseInt(p.width) - lvborder - rvborder - lp.width - parseInt(sp.width) - svborder;
                        } else if (lp.width !== "*" && rp.width !== "*") {
                            h.error("h:left.hposition.width and h:right.hposition.width is not one *");
                            return;
                        }
                        rp.left = parseInt(lp.width) + parseInt(lb.right) + parseInt(lb.left) + parseInt(sp.width) + svborder;
                        right.aLeft = e.aLeft + rp.left;
                        sp.left = parseInt(lp.width) + parseInt(lb.right) + parseInt(lb.left);
                        vsplit.aLeft = e.aLeft + sp.left;
                        vsplit.aTop = e.aTop;
                        lp.Bind(); lb.Bind(); sp.Bind(); sb.Bind(); rp.Bind(); rb.Bind();
                    }
                    if(e.DoLayoutedHandler !=null && h.isFunction(e.DoLayoutedHandler))
                        e.DoLayoutedHandler(e);
                    var leftlayout = GetObjIndexbyLayoutType("h:layout", left.children);
                    if (leftlayout != null)
                        leftlayout.DoLayout();
                    var rightlayout = GetObjIndexbyLayoutType("h:layout", right.children);
                    if (rightlayout != null)
                        rightlayout.DoLayout();
                } else if (head != null && bottom != null) {
                    head.aTop = e.aTop;
                    head.aLeft = e.aLeft;
                    var headp = {}, headb = {}, bottomp = {}, bottomb = {};
                    headp = h.extend(true, headp, head.hposition);
                    headb = h.extend(true, headb, head.borderwidth);
                    bottomp = h.extend(true, bottomp, bottom.hposition);
                    bottomb = h.extend(true, bottomb, bottom.borderwidth);
                    var vheadb = headb.left + headb.right, hheadb = headb.top + headb.bottom, vbottomb = bottomb.left + bottomb.right,
                                                    hbottomb = bottomb.top + bottomb.bottom;

                    if (hspliter == null) {
                        headp.top = p.top; headp.left = bottomp.left = p.left;
                        headp.width = p.width - vheadb; bottomp.width = p.width - vbottomb;
                        if (headp.height === "*" && bottomp.height === "*") {
                            headp.height = bottomp.height = (p.height - hheadb - hbottomb) / 2;
                        } else if (headp.height !== "*" && bottomp.height === "*") {
                            bottomp.height = p.height - parseInt(headp.height) - hheadb - hbottomb;
                        } else if (headp.height === "*" && bottomp.height !== "*") {
                            headp.height = p.height - parseInt(bottomp.height) - hheadb - hbottomb;

                        } else if (headp.height !== "*" && bottomp.height !== "*") {
                            h.error("error:layout h:head OR h:bottom `s hposition.height one *");
                            return;
                        }
                        bottomp.top = parseInt(headp.height) + hheadb;
                        bottom.aTop = e.aTop + bottomp.top;
                        bottom.aLeft = e.aLeft;
                        headp.Bind(); headb.Bind(); bottomp.Bind(); bottomb.Bind();
                    } else {
                        var hsp = {}, hsb = {};
                        hsp = h.extend(true, hsp, hspliter.hposition);
                        hsb = h.extend(true, hsb, hspliter.borderwidth);
                        var hsbborder = hsb.top + hsb.bottom, vsbborder = hsb.left + hsb.right;
                        headp.width = p.width - vheadb;
                        hsp.width = p.width - vsbborder;
                        bottomp.width = p.width - vbottomb;
                        headp.top = p.top;
                        headp.left = hsp.left = bottomp.left = p.left;
                        if (headp.height === "*" && bottomp.height === "*") {
                            headp.height = bottomp.height = (p.height - hsp.height - hsbborder - hheadb - hbottomb) / 2;
                            hspliter.dragObj = { obj: head, layoutObj: e, type: "head" };
                        } else if (headp.height === "*" && bottomp.height !== "*") {
                            hspliter.dragObj = { obj: bottom, layoutObj: e, type: "bottom" };
                            if(headp.height !=0) if(headp.height < head.minheight) headp.height = head.minheight;
                            if(bottomp.height !=0) if(bottomp.height < bottom.minheight) bottomp.height = bottom.minheight;
                            headp.height = p.height - parseInt(bottomp.height) - hheadb - hbottomb - parseInt(hsp.height) - hsbborder;
                        } else if (headp.height !== "*" && bottomp.height === "*") {
                            hspliter.dragObj = { obj: head, layoutObj: e, type: "head" };
                            if(headp.height !=0) if(headp.height < head.minheight) headp.height = head.minheight;
                            if(bottomp.height !=0) if(bottomp.height < bottom.minheight) bottomp.height = bottom.minheight;
                            bottomp.height = p.height - parseInt(headp.height) - hheadb - hbottomb - parseInt(hsp.height) - hsbborder;
                        } else if (headp.height !== "*" && bottomp.height !== "*") {
                            h.error("layout h:head OR h:bottom `s hposition.height one *");
                            return;
                        }
                        hsp.top = parseInt(headp.height) + hheadb;
                        hspliter.aTop = e.aTop + hsp.top;
                        hspliter.aLeft = e.aLeft;
                        bottomp.top = parseInt(headp.height) + parseInt(hsp.height) + hheadb + hsbborder;
                        bottom.aTop = e.aTop + bottomp.top;
                        bottom.aLeft = e.aLeft;
                        headp.Bind(); headb.Bind(); hsp.Bind(); hsb.Bind(); bottomp.Bind(); bottomb.Bind();
                    }
                    if(e.DoLayoutedHandler !=null && h.isFunction(e.DoLayoutedHandler))
                        e.DoLayoutedHandler(e);
                    var headlayout = GetObjIndexbyLayoutType("h:layout", head.children);
                    if (headlayout != null)
                        headlayout.DoLayout();
                    var bottomlayout = GetObjIndexbyLayoutType("h:layout", bottom.children);
                    if (bottomlayout != null)
                        bottomlayout.DoLayout();
                } else {
                    h.error("h:layout content Error");
                    return;
                }
            }
            else { alert("error :h:layout children.length= 0 || 2 || 3"); }
        };
        //#endregion 方法
    };
    h.Defui["h:left"] = h.Defui["h:left"] || {}; h.left = h.Defui["h:left"];
    h.left.Init = function (e) {
        h.Defui.CallTagCheck(e, "h:left", "Init");
        e.typename = h.GetTagName(e);
        e.hposition = new Position(e, (h.Attr(e, "hposition") ? h.Attr(e, "hposition") : "0,0,*,*"));
        e.borderwidth = new Border(e, (h.Attr(e, "borderwidth") ? h.Attr(e, "borderwidth") : "0,0,0,0"));
        e.minwidth = h.Attr(e, "minwidth") ? h.Attr(e, "minwidth") : "0";
        e.minheight = h.Attr(e, "minheight") ? h.Attr(e, "minheight") : "0";
        e.cWidth = null;
        e.aTop = null;
        e.aLeft = null;
        e.isInit = true;
    };

    h.Defui["h:right"] = h.Defui["h:right"] || {}; h.right = h.Defui["h:right"];
    h.right.Init = function (e) {
        h.Defui.CallTagCheck(e, "h:right", "Init");
        e.typename = h.GetTagName(e);
        e.hposition = new Position(e, (h.Attr(e, "hposition") ? h.Attr(e, "hposition") : "0,0,*,*"));
        e.borderwidth = new Border(e, (h.Attr(e, "borderwidth") ? h.Attr(e, "borderwidth") : "0,0,0,0"));
        e.minwidth = h.Attr(e, "minwidth") ? h.Attr(e, "minwidth") : "0";
        e.minheight = h.Attr(e, "minheight") ? h.Attr(e, "minheight") : "0";
        e.cWidth = null;
        e.aTop = null;
        e.aLeft = null;
        e.isInit = true;
    };

    h.Defui["h:vsplitter"] = h.Defui["h:vsplitter"] || {}; h.vsplitter = h.Defui["h:vsplitter"];
    h.vsplitter.Init = function (e) {
        h.Defui.CallTagCheck(e, "h:vsplitter", "Init");
        e.typename = h.GetTagName(e);
        e.hposition = new Position(e, (h.Attr(e, "hposition") ? h.Attr(e, "hposition") : "0,0,5,*"));
        e.borderwidth = new Border(e, (h.Attr(e, "borderwidth") ? h.Attr(e, "borderwidth") : "0,0,0,0"));
        e.dragenabled = h.Attr(e, "dragenabled") ? h.Attr(e, "dragenabled") : "true";
        e.dragObj = null;
        e.aTop = null;
        e.aLeft = null;
        if(e.dragenabled == "true")
        {
            h.addEvent(e, "mousedown", h.vsplitter.OnMouseDown(e), false);
            h.addEvent(e, "dblclick", h.vsplitter.Ondblclick(e), false);
            h.addEvent(e, "click", h.vsplitter.OnClick(e), false);
        }
        else
        {
             e.style.cursor = "pointer";
        }
        e.isInit = true;
        e.Show = function(){ h.vsplitter.Show(this); };
        e.Hid = function(){ h.vsplitter.Hid(this); };
        e.IsHid = function(){
            var obj = e.dragObj.obj;
            if(obj.style.display == "")
                return false;
            else
                return true;
        };
        e.SetHposition=function(hposition)
        {
            e.hposition=new Position(e,hposition);
        };
        e.SetBorderwidth=function(borderwidth){
            e.borderwidth=new Border(e, borderwidth);
        };
        e.DoLayout=function()
        {
          e.dragObj.layoutObj.DoLayout();  
        };
    };
    h.vsplitter.OnMouseDown = function (sender) {
        return function () {
            var e = sender.dragObj.obj;
            if (e.hposition.width != 0) {
                g("iframe", sender.dragObj.layoutObj).each(function () { this.style.display = "none"; });
                h.Drag.SetData(sender.dragObj, function (dragData) {
                    if (dragData.type == "left") {
                        e.hposition.width = h.Page.MouseX - dragData.layoutObj.aLeft;
                    }
                    else {
                        e.hposition.width = (h.GetPageSize().ww - h.Page.MouseX) - (h.GetPageSize().ww - (dragData.layoutObj.aLeft + parseInt(dragData.layoutObj.style.width)));
                    }
                    dragData.layoutObj.DoLayout();
                }, function (dragData) {
                    g("iframe", sender.dragObj.layoutObj).each(function () { this.style.display = ""; });
                });
            }
        };
    };
    h.vsplitter.Ondblclick = function (sender) {
        return function () {
            h.vsplitter.Hid(sender); 
        }
    };
    h.vsplitter.OnClick = function (sender) {
        return function () {
            h.vsplitter.Show(sender); 
        };
    };
    h.vsplitter.Show=function(sender){
        var obj = sender.dragObj.obj;
        if (obj.hposition.width == "0") {
            obj.hposition.width = obj.cWidth;
            obj.style.display="";
            sender.style.cursor = "e-resize";
            sender.dragObj.layoutObj.DoLayout();
        }
    };
    h.vsplitter.Hid=function(sender){
        var obj = sender.dragObj.obj;
        if(obj.hposition.width == 0) return;
        obj.cWidth = obj.hposition.width;
        obj.hposition.width = 0;
        obj.style.display="none";
        sender.style.cursor = "pointer";
        sender.dragObj.layoutObj.DoLayout();
    };

    h.Defui["h:head"] = h.Defui["h:head"] || {}; h.head = h.Defui["h:head"];
    h.head.Init = function (e) {
        h.Defui.CallTagCheck(e, "h:head", "Init");
        e.typename = h.GetTagName(e);
        e.hposition = new Position(e, (h.Attr(e, "hposition") ? h.Attr(e, "hposition") : "0,0,*,*"));
        e.borderwidth = new Border(e, (h.Attr(e, "borderwidth") ? h.Attr(e, "borderwidth") : "0,0,0,0"));
        e.minwidth = h.Attr(e, "minwidth") ? h.Attr(e, "minwidth") : "0";
        e.minheight = h.Attr(e, "minheight") ? h.Attr(e, "minheight") : "0";
        e.cWidth = null;
        e.aTop = null;
        e.aLeft = null;
        e.isInit = true;
    };
    h.Defui["h:hsplitter"] = h.Defui["h:hsplitter"] || {}; h.hsplitter = h.Defui["h:hsplitter"];
    h.hsplitter.Init = function (e) {
        h.Defui.CallTagCheck(e, "h:hsplitter", "Init");
        e.typename = h.GetTagName(e);
        e.hposition = new Position(e, (h.Attr(e, "hposition") ? h.Attr(e, "hposition") : "0,0,*,5"));
        e.borderwidth = new Border(e, (h.Attr(e, "borderwidth") ? h.Attr(e, "borderwidth") : "0,0,0,0"));
        e.dragenabled = h.Attr(e, "dragenabled") ? h.Attr(e, "dragenabled") : "true";
        e.dragObj = null;
        e.aTop = null;
        e.aLeft = null;
        if(e.dragenabled === "true")
        {
            h.addEvent(e, "mousedown", h.hsplitter.OnMouseDown(e), false);
            h.addEvent(e, "dblclick", h.hsplitter.Ondblclick(e), false);
            h.addEvent(e, "click", h.hsplitter.OnClick(e), false);
        }
        else
        {
             e.style.cursor = "pointer";
        }
        e.isInit = true;
        e.Show = function(){ h.hsplitter.Show(this); };
        e.Hid = function(){ h.hsplitter.Hid(this); };
        e.IsHid = function(){
            var obj = e.dragObj.obj;
            if(obj.style.display == "")
                return false;
            else
                return true;
        };
        e.DoLayout=function()
        {
          e.dragObj.layoutObj.DoLayout();  
        };
    };
    h.hsplitter.OnMouseDown = function (sender) {
        return function () {
            var e = sender.dragObj.obj;
            if (e.hposition.height != 0) {
                g("iframe", sender.dragObj.layoutObj).each(function () { this.style.display = "none"; });
                h.Drag.SetData(sender.dragObj, function (dragData) {
                    if (dragData.type == "head") {
                        e.hposition.height = h.Page.MouseY - dragData.layoutObj.aTop;
                    }
                    else {
                        e.hposition.height = (h.GetPageSize().wh - h.Page.MouseY) - (h.GetPageSize().wh - (dragData.layoutObj.aTop + parseInt(dragData.layoutObj.style.height)));
                    }
                    dragData.layoutObj.DoLayout();
                },function(dragData){
                      g("iframe", sender.dragObj.layoutObj).each(function () { this.style.display = ""; });
                });
            }
        };
    };
    h.hsplitter.Ondblclick = function (sender) {
        return function () {
            h.hsplitter.Hid(sender);
        };
    }
    h.hsplitter.OnClick = function (sender) {
        return function () {
            h.hsplitter.Show(sender);
        };
    };
    h.hsplitter.Show=function(sender)
    {
        var obj = sender.dragObj.obj;
        if (obj.hposition.height == "0") {
            obj.hposition.height = obj.cWidth;
            obj.style.display="";
            sender.style.cursor = "n-resize";
            sender.dragObj.layoutObj.DoLayout();
        }
    };
    h.hsplitter.Hid=function(sender)
    {
        var obj = sender.dragObj.obj;
        if(obj.hposition.height == 0) return;
        obj.cWidth = obj.hposition.height;
        obj.hposition.height = 0;
        obj.style.display="none";
        sender.style.cursor = "pointer";
        sender.dragObj.layoutObj.DoLayout();
    };

    h.Defui["h:bottom"] = h.Defui["h:bottom"] || {}; h.bottom = h.Defui["h:bottom"];
    h.bottom.Init = function (e) {
        h.Defui.CallTagCheck(e, "h:bottom", "Init");
        e.typename = h.GetTagName(e);
        e.hposition = new Position(e, (h.Attr(e, "hposition") ? h.Attr(e, "hposition") : "0,0,*,*"));
        e.borderwidth = new Border(e, (h.Attr(e, "borderwidth") ? h.Attr(e, "borderwidth") : "0,0,0,0"));
        e.minwidth = h.Attr(e, "minwidth") ? h.Attr(e, "minwidth") : "0";
        e.minheight = h.Attr(e, "minheight") ? h.Attr(e, "minheight") : "0";
        e.cWidth = null;
        e.aTop = null;
        e.aLeft = null;
        e.isInit = true;
    };
    //#endregion h:layout 
    //#region h:listview
    h.Defui["h:listview"] = h.Defui["h:listview"] || {}; h.ListView = h.Defui["h:listview"];
    h.ListView.Init = function (e) {
        if (e.id == undefined) { h.error("h:listview is not setting id"); return; }
        e.isInit = true;
        var t = g("h:itemTemplet", e)[0];
        if (t == undefined) {
            h.error("id=" + e.id + "not find h:ItemTemplet");
            return;
        }
        var c = d.createElement("h:content");
        t.className = "Templet";
        e.ItemTemplet = t.innerHTML;
        e.Content = c;
        e.appendChild(e.Content);
        e.Data = null;
        e.Items = null;
        e.TabControlPanel = null;
        e.itemcss = h.Attr(e, "itemcss") ? h.Attr(e, "itemcss") : "itemcss";
        e.itemcsshover = h.Attr(e, "itemcsshover") ? h.Attr(e, "itemcsshover") : "itemcsshover";
        e.itemselectcss = h.Attr(e, "itemselectcss") ? h.Attr(e, "itemselectcss") : "itemselectcss";
        e.ismultiselect = h.Attr(e, "ismultiselect") ? h.Attr(e, "ismultiselect") : "false";
        e.iskeyselect = h.Attr(e, "iskeyselect") ? h.Attr(e, "iskeyselect") : "true";
        e.tabcss = h.Attr(e, "tabcss") ? h.Attr(e, "tabcss") : "listview_tab";
        e.istab = h.Attr(e, "istab") ? h.Attr(e, "istab") : "false";
        e.isUnSelectedInOnClick = h.Attr(e, "isunselectedinonclick") ? h.Attr(e, "isunselectedinonclick") : "true";
        e.tabmovepx = h.Attr(e, "tabmovepx") ? h.Attr(e, "tabmovepx") : "50";
        e.tabmovepx = parseInt(e.tabmovepx);
        e.iskeymultiselect = e.ismultiselect ;
        //e.OnItemClick = h.Attr(e, "OnItemClick") ? h.Attr(e, "OnItemClick") : "";
        e.keyStartSelectIndex=-1; //连继选择开始索引
        e.keyEndSelectIndex=-1;//连继选择结束索引
        e.isContinueSelect=false;
        e.SelectChangeHandler = null;
        e.IsBind = false;
        if (e.istab === "true") {
            e.className = e.tabcss;
            h.addEvent(e, "mouseout", h.ListView.OnMouseOut(e), false);
            h.addEvent(e, "mousemove", h.ListView.OnMouseMove(e), false);
            e.Content.className = "tabContent";
            e.Content.style.position = "absolute";
            e.Content.style.left = "0px";
            e.TabControlPanel = d.createElement("div");
            e.TabControlPanel.style.position = "absolute";
            e.TabControlPanel.style.width = "100%";
            e.TabControlPanel.style.height = "0px";
            e.TabControlPanel.style.top = "0px";
            e.TabControlPanel.style.display = "none";
            var leftbtnid = e.id + "lbtn";
            var rbtnid = e.id + "rbtn";
            e.TabControlPanel.innerHTML = "<h:btn css='TabLeftBtn' csshover='TabLeftBtn_Hover' id='" + leftbtnid + "' ></h:btn><h:btn css='TabRightBtn' csshover='TabRightBtn_Hover' id='" + rbtnid + "'></h:btn>";
            e.appendChild(e.TabControlPanel);
            h.InitDom(e.TabControlPanel);
            var lbtn = g("#" + leftbtnid);
            var rbtn = g("#" + rbtnid);
            h.addEvent(lbtn, "click", h.ListView.OnLeftBtnClick(e), false);
            h.addEvent(rbtn, "click", h.ListView.OnRightBtnClick(e), false);
        }
        e.OnBindCompleted = null;
        e.OnItemClick=null;
        e.OnRowBinding = null;
        e.OnRowBinded = null;
        e.ItemMouseOverHandle = null;
        e.ItemMouseOutHandle = null;
        e.MouseMoveHandle = null;
        e.MouseOutHandle = null;
        e.OnLeftBtnClick=null;
        e.RightBtnClickHandle = null;
        if(e.iskeyselect == "true")
        {
            e.tabIndex=0;
            h.addEvent(e,"keydown",function(){
                var evt = h.GetEvent();
                var keycode = h.key.GetKeyCode(evt);
                if(evt.ctrlKey)
                {
                    if(e.iskeymultiselect == e.ismultiselect)
                    {
                        e.iskeymultiselect=e.ismultiselect;
                    }
                    e.ismultiselect="true";
                       h.IsSelectionTest(d.body,false);
                }
                if(evt.shiftKey)
                {
                    if(e.iskeymultiselect == e.ismultiselect)
                    {
                        e.iskeymultiselect=e.ismultiselect;
                    }
                    e.ismultiselect="true";
                    e.isContinueSelect = true;
                         h.IsSelectionTest(d.body,false);
                }
           
            });
            h.addEvent(e,"keyup",function(){
                e.ismultiselect = e.iskeymultiselect;
                e.isContinueSelect = false;
                h.IsSelectionTest(d.body,true);
            });
            h.addEvent(e,"focus",function(){
                var evt = h.GetEvent();
            });
            h.addEvent(e,"blur",function(){
                 h.IsSelectionTest(d.body,true);
            });
        }
        //#region 方法
        e.SetData=function(data){
            this.Data = data;
        };
        e.Bind = function (data,isReBind,CompletedHandler) {
            if(data != undefined)
                e.Data = data;
            if (e.Data == null)
                    return;
             if(isReBind==true)
                e.IsBind = false;
            if (e.IsBind == true) {
                return;
            }
            e.Items = new Array();
            var html = new h.StringBuilder();
            var html2="";
            //e.Content.innerHTML="正在加载,请等待......";
            h.eachAsy(e.Data,function(i,v){
                i = parseInt(i);
                if (e.OnRowBinding != null)
                    e.OnRowBinding(e, i);
                var itemclick = "";
    //            if (e.OnItemClick !="" && typeof (e.OnItemClick) == "string") {
    //                itemclick = new h.StringBuilder([e.OnItemClick , "('",e.id,"'," , i , ");"]).ToString();
    //            }
                var itemid = new h.StringBuilder([e.id,"item",i]).ToString();
                var OnMouseOverStr = new h.StringBuilder([_hname , ".ListView.OnItemMouseOver('",e.id,"'," , i , ");"]).ToString();
                var OnMouseOutStr = new h.StringBuilder([_hname , ".ListView.OnItemMouseOut('",e.id,"'," , i , ");"]).ToString();
                var OnClickStr = new h.StringBuilder([_hname , ".ListView.OnItemClick('",e.id,"'," , i , ");" , itemclick]).ToString();
                html.Add("<div id=\"" + itemid +"\" onmousemove=\""+ OnMouseOverStr+ "\" onmouseout=\""+
                                            OnMouseOutStr+ "\"  onclick=\""+ OnClickStr + "\" class=\""+ e.itemcss + "\">"+ h.GetDataFromTemplet(e.ItemTemplet, i, e.Data) +
                                            "</div>");
                e.Items[i] = {
                    id: "#" + itemid,
                    ParentObj: e,
                    Selected: false,
                    GetObj: function () {
                        return g(this.id, this.ParentObj);
                    }
                };
            },function(){
                  e.Content.innerHTML = html.ToString();
                  //e.Content.innerHTML = html2;
                  h.ReInitDom(e);
                    //执行绑定后操作。
                    for (i in e.Items) {
                        i = parseInt(i);
                        var item = e.Items[i];
                        var obj = item.GetObj();
                        if (e.OnRowBinded != null)
                            e.OnRowBinded(e, obj, i);
                    }
                    e.IsBind = true;

                    if (e.OnBindCompleted != null) {
                        e.OnBindCompleted(e);
                    }

                    if(CompletedHandler != null){
                        CompletedHandler(e);
                    }

                    
            });
        };
        e.BindState = function () {
            for (var i in e.Items) {
                i = parseInt(i);
                var item = e.Items[i];
                var obj = item.GetObj();
                if (item.Selected == true)
                    obj.className = e.itemselectcss;
                else
                    obj.className = e.itemcss;
            }
        };
        e.Select = function (index) {
            if (e.Items[index] == undefined)
                return false;
            var item = e.Items[index];
            var itemObj = item.GetObj();
            if(itemObj == null) return;
            if (e.ismultiselect === "false") {
                e.UnSelectAll();
            }
            item.Selected = true;
            itemObj.className = e.itemselectcss;
            if (e.SelectChangeHandler != null)
                e.SelectChangeHandler(e, index);
            return true;
        };
        e.UnSelect = function (index) {
            if (this.Items[index] == undefined)
                return false;
            var item = e.Items[index];
            var obj = item.GetObj();
            if(obj == null) return;
            item.Selected = false;
            obj.className = e.itemcss;
            if (e.SelectChangeHandler != null)
                e.SelectChangeHandler(e, index);
            return true;
        };
        e.SelectAll = function () {
            for (var i in e.Items) {
                i = parseInt(i);
                e.Select(i);
            }
        };
        e.UnSelectAll = function () {
            for (var i in this.Items) {
                i = parseInt(i);
               this.UnSelect(i);
            }
        };
        e.GetSelect = function () {
            var selectIndex = new Array();
            for (var i in e.Items) {
                i = parseInt(i);
                var item = e.Items[i];
                var data = e.Data[i];
                if (item.Selected == true)
                    selectIndex.push({ obj: item, index: parseInt(i),data:data });
            }
            return selectIndex;
        };
        e.DeleteItem = function (index) {
            if (e.Items[index] == undefined)
                return;
            var item = e.Items[index];
            var itemObj = item.GetObj();
            e.Content.removeChild(itemObj);
            delete e.Items[index];
            delete e.Data[index];
        };
        e.AddItem = function (obj) {
            var i = e.Data.length;
            e.Data[i] = obj;
        
            if (e.OnRowBinding != null)
                e.OnRowBinding(e, i);
            var itemclick = "";
            if (e.OnItemClick != "" && typeof (e.OnItemClick) == "string") {
                itemclick = e.OnItemClick + "('"+e.id+"'," + i + ");";
            }
            var itemid = e.id + "item" + i;
            var OnMouseOverStr = _hname + ".ListView.OnItemMouseOver('"+e.id+"'," + i + ");";
            var OnMouseOutStr = _hname + ".ListView.OnItemMouseOut('"+e.id+"'," + i + ");";
            var OnClickStr = _hname + ".ListView.OnItemClick('"+e.id+"'," + i + ");" + itemclick;

            e.Content.innerHTML = e.Content.innerHTML + "<div id=\"" + itemid + "\" onmousemove=\"" + OnMouseOverStr + "\" onmouseout=\"" +
                                        OnMouseOutStr + "\"  onclick=\"" + OnClickStr + "\"  class=\"" + e.itemcss + "\">" + h.GetDataFromTemplet(e.ItemTemplet, i, e.Data) +
                                        "</div>";
            e.Items[i] = {
                id: "#" + itemid,
                ParentObj: e,
                Selected: false,
                GetObj: function () {
                    return g(this.id, this.ParentObj);
                }
            };

            h.ReInitDom(e.Content);
            var itemObj = e.Items[index].GetObj();
            itemObj.className = e.itemcss;
        };
        e.UpdateItem = function(i)
        {
             if (e.OnRowBinding != null)
                    e.OnRowBinding(e, i);
             var itemid = e.id + "item" + i;
             var item = g("#"+itemid);
             item.html(h.GetDataFromTemplet(e.ItemTemplet, i, e.Data));
            var obj = e.Items[i];
            if (e.OnRowBinded != null)
                    e.OnRowBinded(e, obj, i);
        };
        //#endregion 方法
    };
    h.ListView.OnItemMouseOver = function (listid, index) {
        var lv = g("#"+listid);
        if(lv ==null || lv == undefined || lv.Items == undefined)
            return;
        try{
            if (lv.Items[index].Selected == false)
                lv.Items[index].GetObj().className = lv.itemcsshover;
            if(lv.ItemMouseOverHandle !=null && typeof (lv.ItemMouseOverHandle) == "function")
            {
                var itemdom =  lv.Items[index].GetObj();
                lv.ItemMouseOverHandle(lv,index,itemdom);
            }
        }catch(e){}
    };
    h.ListView.OnMouseMove = function (lv) {
        return function () {
            var content = lv.Content;
            var w = parseInt(lv.scrollWidth);
            var cw = parseInt(content.clientWidth);
            var condition = w - (cw + parseInt(content.style.left));
            if (condition <= 0) {
                lv.TabControlPanel.style.display = "";
            }
            else {
                content.style.left = "0px";
                lv.TabControlPanel.style.display = "none";
            }
            if(lv.MouseMoveHandle !=null && typeof (lv.MouseMoveHandle) == "function")
            {
                lv.MouseMoveHandle(lv);
            }
        };
    };
    h.ListView.OnMouseOut = function (lv) {
        return function () {
            lv.TabControlPanel.style.display = "none";
             if(lv.MouseOutHandle !=null && typeof (lv.MouseOutHandle) == "function")
            {
                lv.MouseOutHandle(lv);
            }
        };
    };
    h.ListView.OnItemMouseOut = function (listid, index) {
       var lv = g("#"+listid);
        if(lv.Items == undefined || lv.Items == null)
            return;
         try
         {
            if (lv.Items[index].Selected == false)
                lv.Items[index].GetObj().className = lv.itemcss;
            if(lv.ItemMouseOutHandle !=null  && typeof (lv.ItemMouseOutHandle) == "function")
            {
                var itemdom =  lv.Items[index].GetObj();
                lv.ItemMouseOutHandle(lv,index,itemdom);
            }
        }catch(e){}
    };
    h.ListView.OnItemClick = function (listid, index) {
        var lv = g("#"+listid);
        if(lv == null)
            return;
        var item = lv.Items[index];
        if (lv.isUnSelectedInOnClick == "true") {
            if (item.Selected)
                lv.UnSelect(index);
            else
                lv.Select(index);
        }
        else {
            lv.Select(index);
        }
           
        if(lv.iskeyselect == "true")
        {
            if(lv.isContinueSelect)
            {
                 lv.keyEndSelectIndex=index;
                 h.ListView.ContinueSelect(lv,lv.keyStartSelectIndex,lv.keyEndSelectIndex);
            }
            else
            {
                 lv.keyStartSelectIndex=index;
            }
        }
        if (lv.OnItemClick != null && typeof (lv.OnItemClick) == "function")
            lv.OnItemClick(lv, item.GetObj(), index);
    };
    h.ListView.OnLeftBtnClick = function (lv) {
        return function () {
            var ccw = parseInt(lv.Content.clientWidth);
            var clw = parseInt(lv.Content.style.left);
            var lvsw = parseInt(lv.scrollWidth);
            var currentCW = ccw + clw - lv.tabmovepx;
            if (currentCW < lvsw) {
                lv.Content.style.left = (clw - lv.tabmovepx) + (lvsw - currentCW) + "px";
            }
            else {
                lv.Content.style.left = (clw - lv.tabmovepx) + "px";
            }
            if (lv.LeftBtnClickHandle != null && typeof (lv.LeftBtnClickHandle) == "function")
                lv.LeftBtnClickHandle(lv);
        };
    };
    h.ListView.OnRightBtnClick = function (lv) {
        return function () {
            var clw = parseInt(lv.Content.style.left);
            var currentCW = clw + lv.tabmovepx;
            if (currentCW < 0) {
                lv.Content.style.left = (clw + lv.tabmovepx) + "px";
            }
            else {
                lv.Content.style.left = "0px";
            }
            if (lv.RightBtnClickHandle != null && typeof (lv.RightBtnClickHandle) == "function")
                lv.RightBtnClickHandle(lv);

        };
    };
    h.ListView.ContinueSelect=function(e,sIndex,eIndex){
        if(sIndex >=eIndex)
        {
            for(var i=sIndex,j=eIndex;i>=j;i--)
            {
                e.Select(i);
            }
        }
        else
        {
            for(var i=sIndex,j=eIndex;i<=j;i++)
            {
                e.Select(i);
            }
        }
    };
    //h.Defui["h:ItemTemplet"] = {};
    //#endregion h:listview
    //#region h:grid
    h.Defui["h:grid"] = h.Defui["h:grid"]||{};h.Grid=h.Defui["h:grid"];
    h.Grid.Init=function(e){
        if (e.id == undefined) { alert("h:grid is not setting id"); return; }
        e.layoutid = h.Attr(e, "layoutid") ? h.Attr(e, "layoutid") : ""; 
        if (e.layoutid  != "") {
            e.layoutobj = g("#"+e.layoutid);
            e.pelem = e.parentNode; //父对像
            e.layoutobj.DoLayoutedHandler=function(layout){
                h.Grid.DoLayout(e);
            }
        }
        e.ismultiselect=h.Attr(e, "ismultiselect") ? h.Attr(e, "ismultiselect") : "false";//是否起用多选
        e.iskeymultiselect = e.ismultiselect ;
        e.isContinueSelect=false;
        e.keyStartSelectIndex=-1;
        e.keyEndSelectIndex=-1;
        e.showheader = h.Attr(e, "showheader") ? h.Attr(e, "showheader") : "true"; //是否显示头
        e.borderwidth = new Border(e, (h.Attr(e, "borderwidth") ? h.Attr(e, "borderwidth") : "1,1,1,1")); //设置边框宽度
        e.headerrowborder =new Border(null, (h.Attr(e, "headerrowborder") ? h.Attr(e, "headerrowborder") : "0,1,0,1")); //设置边框宽度
        e.headercellborder =new Border(null, (h.Attr(e, "headercellborder") ? h.Attr(e, "headercellborder") : "1,1,1,1")); //设置边框宽度
        e.rowborder = new Border(null, (h.Attr(e, "rowborder") ? h.Attr(e, "rowborder") : "1,1,1,1")); //设置边框宽度
        e.cellborder = new Border(null, (h.Attr(e, "cellborder") ? h.Attr(e, "cellborder") : "0,1,0,1")); //设置边框宽度
        e.headerheight = parseInt(h.Attr(e, "headerheight") ? h.Attr(e, "headerheight") : "25"); //设置头的高度
        e.rowheight=parseInt(h.Attr(e, "rowheight") ? h.Attr(e, "rowheight") : "20"); //设置行的高度
        e.isUnSelectedInOnClick = h.Attr(e, "isUnSelectedInOnClick") ? h.Attr(e, "isUnSelectedInOnClick") : "true";
        e.iskeyselect=h.Attr(e, "iskeyselect") ? h.Attr(e, "iskeyselect") : "true";//设置键盘事件是否启用
        //设置样式---------------
        e.headerboxcss=h.Attr(e, "headerboxcss") ? h.Attr(e, "headerboxcss") : "headerbox"; //设置头容器的样式
        e.contentboxcss=h.Attr(e, "contentboxcss") ? h.Attr(e, "contentboxcss") : "contentbox"; //设置内容容器的样式
        e.rowcss=h.Attr(e, "rowcss") ? h.Attr(e, "rowcss") : "rowcss"; //设置行样式
        e.rowcsshover=h.Attr(e, "rowcsshover") ? h.Attr(e, "rowcsshover") : "rowcsshover"; //设置行鼠标移上去时的样式
        e.rowcssactive=h.Attr(e, "rowcssactive") ? h.Attr(e, "rowcssactive") : "rowcssactive"; //设置行被选中时的样式
        e.cellcss=h.Attr(e, "cellcss") ? h.Attr(e, "cellcss") : "cellcss"; //设置行样式
        e.cellcsshover=h.Attr(e, "cellcsshover") ? h.Attr(e, "cellcsshover") : "cellcsshover"; //设置行样式
        e.cellcssactive=h.Attr(e, "cellcssactive") ? h.Attr(e, "cellcssactive") : "cellcssactive"; //设置行样式
        e.headerrowcss=h.Attr(e, "headerrowcss") ? h.Attr(e, "headerrowcss") : "headerrowcss"; //设置行被选中时的样式
        e.headercss=h.Attr(e, "headercss") ? h.Attr(e, "headercss") : "headercss"; //设置行被选中时的样式
        e.headercsshover=h.Attr(e, "headercsshover") ? h.Attr(e, "headercsshover") : "headercsshover"; //设置行被选中时的样式
        e.headercssactive=h.Attr(e, "headercssactive") ? h.Attr(e, "headercssactive") : "headercssactive"; //设置行被选中时的样式
        //end 设置样式式-----------------------------------
        //事件
        e.OnRowBinding = null;
        e.OnRowBinded=null;
        e.OnCellBinded=null;
        e.OnHeaderItemClick = null;
        e.HeaderItemClickHandle= null;
        e.HeaderItemMouseOverHandle=null;
        e.SortHandle = null;
        e.HeaderItemMouseOutHandle=null;
        e.HeaderSelectChangeHandler=null;
        e.SelectChangeHandler=null;
        e.OnItemClick=h.Attr(e, "OnItemClick") ? h.Attr(e, "OnItemClick") : "";
        e.ItemMouseOverHandle=null;
        e.ItemMouseOutHandle=null;
        e.BindedHandler=null;
        //end 事件
        e.borderwidth.Bind(); 
        e.columns=h.Grid.InitColumns(e);
        e.haveAutoColums =e.columns.widthauto.length>0?true:false;//是否有宽度为"*"的列
        e.haveHscroll = false; //是否出现垂直滚动条
        e.CurrentScrollLeft=0; //当前水平滚动条位置
        e.CurrentscrollTop =0; //当前垂直滚动条位置
        e.rdrawhaveHscrollsE = false;
        var html = "<div id='"+e.id+"_headerbox' class='"+e.headerboxcss+"' style='overflow:hidden;'>headerbox</div>"+
        "<div id='"+e.id+"_contentbox' class='"+e.contentboxcss+"'  style='overflow:auto;'></div>";
        e.innerHTML = html;
        h.ReInitDom(e);
        e.headerbox = g("#"+e.id+"_headerbox",e);
        e.headerbox.style.display="none";
        e.contentbox = g("#"+e.id+"_contentbox",e);
        _h.addEvent(e.contentbox,"scroll",function(){
             e.headerbox.scrollLeft=e.contentbox.scrollLeft;
             if(e.IsBind)
             {
                e.CurrentScrollLeft= e.contentbox.scrollLeft;
                e.CurrentscrollTop = e.contentbox.scrollTop;
             }
        });
        h.Grid.InitColumnsHtml(e);
        e.columns.headerrow.E=g("#"+e.columns.headerrow.id,e.headerbox);
        e.Data = null;
        e.IsBind = false;
        e.tabIndex=0;
        e.pelem = e.parentNode; //父对象
        if(e.iskeyselect == "true")
        {
            e.tabIndex=0;
            h.addEvent(e,"keydown",function(){
                var evt = h.GetEvent();
                var keycode = h.key.GetKeyCode(evt);
                if(evt.ctrlKey)
                {
                    if(e.iskeymultiselect == e.ismultiselect)
                    {
                        e.iskeymultiselect=e.ismultiselect;
                    }
                    e.ismultiselect="true";
                       h.IsSelectionTest(d.body,false);
                }
                if(evt.shiftKey)
                {
                    if(e.iskeymultiselect == e.ismultiselect)
                    {
                        e.iskeymultiselect=e.ismultiselect;
                    }
                    e.ismultiselect="true";
                    e.isContinueSelect = true;
                         h.IsSelectionTest(d.body,false);
                }
           
            });
            h.addEvent(e,"keyup",function(){
                e.ismultiselect = e.iskeymultiselect;
                e.isContinueSelect = false;
                h.IsSelectionTest(d.body,true);
            });
            h.addEvent(e,"focus",function(){
                var evt = h.GetEvent();
            });
            h.addEvent(e,"blur",function(){
                 h.IsSelectionTest(d.body,true);
            });
        }
        e.isInit = true;
    };
    h.Grid.DoLayout = function(e){
        var parentElement = e.pelem;
        var pSize = {w:parseInt(parentElement.style.width),h:parseInt(parentElement.style.height)};
        pSize.w=pSize.w-e.borderwidth.left-e.borderwidth.right;
        pSize.h=pSize.h-e.borderwidth.top-e.borderwidth.bottom;
        e.style.width =pSize.w <=0?"0px":pSize.w+"px";
        e.style.height =pSize.h <=0?"0px":pSize.h+"px";
        e.headerbox.style.width =e.style.width;
        e.headerbox.style.height =(e.headerheight)+"px";
        e.contentbox.style.width = e.style.width;
        e.contentbox.style.height=(pSize.h-e.headerheight <= 0 ? 0:pSize.h-e.headerheight) +"px";
        e.contentbox.size = {w:pSize.w,h:parseInt(e.contentbox.style.height)};
        h.Grid.DolayoutHeader(e);
        h.Grid.DolayoutContent(e);
    };
    h.Grid.DolayoutHeader = function(e)
    {
        var columns = e.columns;
        if(e.Data ==null || columns.widthnotauto == undefined || columns.widthnotauto.length <=0) return;
        columns.widthautowidth=0;
        columns.widthnotautowidth=0;
        var rb=e.headerrowborder,cb=e.headercellborder;
        var totalwidth = e.contentbox.clientWidth-rb.left-rb.right;
        for(var i=columns.widthnotauto.length;i--;)
        {
            var cell=columns.widthnotauto[i];
            var cellE=cell.GetE();
            cellE.style.width=(cell.width-cb.left-cb.right)+"px";
            columns.widthautowidth=columns.widthautowidth+ parseInt(cell.width);
        }
         var celllength = columns.widthauto.length;
         var isfool = false; //是否有余数
         if((totalwidth-columns.widthautowidth)%celllength !=0)
         {
            isfool=true;
            autowidth=Math.floor((totalwidth-columns.widthautowidth)/celllength);
         }
         else
         {
              autowidth=(totalwidth-columns.widthautowidth)/celllength;
         }
        for(var i=celllength;i--;)
        {
            var cell=columns.widthauto[i];
            var cellE=cell.GetE();
             if(isfool && i==0)
                autowidth=autowidth+1;
            if(autowidth <=cell.minwidth)
                autowidth = cell.minwidth;
            
            cellE.style.width=(autowidth-cb.left-cb.right)+"px";
            cell.width=parseInt(autowidth);
            columns.widthnotautowidth=columns.widthnotautowidth+parseInt(cell.width);
        }

       e.columns.headerrow.E.style.width=(columns.widthautowidth+columns.widthnotautowidth)+"px";
       e.headerbox.style.display="";
    };
    h.Grid.DolayoutRow=function(e,index)
    {
        if(e.Items[index] == null)
            return;
        var columns = e.columns;
        if(e.Data ==null || columns.widthnotauto == undefined ||columns.widthnotauto.length <=0) return;
        columns.widthautowidth=0;
        columns.widthnotautowidth=0;
        var rb=e.rowborder,cb=e.cellborder;
        var totalwidth = e.contentbox.clientWidth-rb.left-rb.right;
       
        var celllength = columns.widthauto.length;
        for(var i=columns.widthnotauto.length;i--;)
        {
            var cell=columns.widthnotauto[i];
            var cellE=e.Items[index].Items[cell.index].GetE();
            cellE.style.width=(cell.width-cb.left-cb.right)+"px";
            columns.widthautowidth=columns.widthautowidth+ parseInt(cell.width);
        }

         var isfool = false; //是否有余数
         if((totalwidth-columns.widthautowidth)%celllength !=0)
         {
            isfool=true;
            autowidth=Math.floor((totalwidth-columns.widthautowidth)/celllength);
         }
         else
         {
              autowidth=(totalwidth-columns.widthautowidth)/celllength;
         }
         
        for(var i=celllength;i--;)
        {
            var cell=columns.widthauto[i];
            var cellE=e.Items[index].Items[cell.index].GetE();
            if(isfool && i==0)
                autowidth=autowidth+1;
            if(autowidth <=cell.minwidth)
                autowidth = cell.minwidth;
            cellE.style.width=(autowidth-cb.left-cb.right)+"px";
            cell.width=autowidth;
            columns.widthnotautowidth=columns.widthnotautowidth+parseInt(cell.width);
        }
      e.Items[index].GetE().style.width=(columns.widthautowidth+columns.widthnotautowidth)+"px";

    };
    h.Grid.DolayoutContent = function(e)
    {
         if(e.Data ==null || e.IsBind == false) return;
        //执行绑定后操作。
        for (var i=0,j=e.Items.length;i<j;i++) {
            i = parseInt(i);
            h.Grid.DolayoutRow(e,i);
        }

    };
    h.Grid.Bind = function(e,data,isReBind,CompletedHandler)
    {
         if(data != undefined)
            e.Data = data;
        if (e.Data == null)
                return;
         if(isReBind==true)
            e.IsBind = false;
        if (e.IsBind == true) {
            return;
        }
        e.headerbox.style.display="none";
        e.haveHscroll=false;
        e.rdrawhaveHscrollsE=false;
        h.Grid.DolayoutHeader(e);
        var itemclick = "";
        e.Items = e.Items ||{};
         e.Items.length=0;
        //var html ="<div id='"+e.id+"_contenttable' style=''>";
         e.contentbox.innerHTML = "";
        var cb = e.cellborder,rb=e.rowborder;
        h.eachAsy(e.Data,function(i,v){
                var OnMouseOverStr = new h.StringBuilder([_hname , ".Grid.OnItemMouseOver('",e.id,"'," , i , ");"]).ToString();
                var OnMouseOutStr = new h.StringBuilder([_hname , ".Grid.OnItemMouseOut('",e.id,"'," , i , ");"]).ToString();
                if (e.OnItemClick !="" && typeof (e.OnItemClick) == "string") {
                    itemclick = new h.StringBuilder([e.OnItemClick , "('",e.id,"'," , i , ");"]).ToString();
                }
                var OnClickStr = new h.StringBuilder([_hname , ".Grid.OnItemClick('",e.id,"'," , i , ");" , itemclick]).ToString();
                var itemid=e.id+"_contentrow_"+i;
                if(e.OnRowBinding !=null) e.OnRowBinding(e, i);
               var rowe = d.createElement("div");
               rowe.id=itemid;
               rowe.className = e.rowcss;
               var style= "display:block;border-style:solid; border-width: "+rb.top+"px "+rb.right+"px "+rb.bottom+"px "+rb.left+"px; ";
               rowe.setAttribute("style",style);
               h.addEvent(rowe,"click",function(){h.Grid.OnItemClick(e.id,i);});
               h.addEvent(rowe,"mouseover",function(){h.Grid.OnItemMouseOver(e.id,i);});
               h.addEvent(rowe,"mouseout",function(){h.Grid.OnItemMouseOut(e.id,i);});
               var html="";
//               html=html+"<div id='"+itemid+"' class='"+e.rowcss+"' style='display:block;border-style:solid; border-width: "+
//                        rb.top+"px "+rb.right+"px "+rb.bottom+"px "+rb.left+"px; ' onclick=\""+OnClickStr+"\" onmouseover =\""+OnMouseOverStr+"\" onmouseout=\""+OnMouseOutStr+"\">";
                var columns = e.columns;
                var columnsE = {};
                columnsE.length=columns.length;
                for(var j = 0,k=columnsE.length;j<k;j++)
                {
                    if(columns[j].isshow == "true")
                    {
                        var cellid=e.id+"_cell_"+i+"_"+j;
                        columnsE[j]={};
                        columnsE[j].id=cellid;
                        columnsE[j].GetE=function(){
                            return   g("#"+this.id,e);
                        };
                        html =html+ "<div id='"+cellid+"' class='"+e.cellcss+"' style='"+columns[j].data.Style+"float:left;border-style:solid solid solid solid; border-width:"+cb.top+"px "+cb.right+"px "+cb.bottom+"px "+cb.left+"px; height:"+e.rowheight+"px; ' >"+
                            h.GetDataFromTemplet(columns[j].data.templete, i, e.Data)+"</div>";
                     }
                }
                //html = html+"<div style='clear: both;'></div></div>";
                 html = html+"<div style='clear: both;'></div>";
                 rowe.innerHTML = html;
                 var refdom = (e.Items.length>0)?e.Items[0].GetE():null;
                 e.contentbox.insertBefore(rowe,refdom);
                 h.ReInitDom(rowe);
                e.Items[i] = {
                    id: itemid,
                    ParentObj: e,
                    Selected: false,
                    GetE: function () {
                        return  g("#"+this.id, this.ParentObj);
                    },
                    Index:i,
                    data:v,
                    Items:columnsE
                };

               if(!e.haveHscroll)
                   e.haveHscroll = ((e.contentbox.scrollHeight- e.contentbox.clientHeight)>0)?true:false;
                //当出现滚动条时。重新计算宽度。
               if(e.haveHscroll && !e.rdrawhaveHscrollsE)
               {
                    for(var a=0;a<i;a++)
                           h.Grid.DolayoutRow(e,a);
                    e.rdrawhaveHscrollsE=true;
               }
                h.Grid.DolayoutRow(e,i);
                if (e.OnRowBinded != null)
                    e.OnRowBinded(e,rowe,i);
        },function(){
                //html = html+"</div>";
//                e.contentbox.innerHTML = html;
//                h.ReInitDom(e);
                e.Items.length=e.Data.length;
                e.Items.count= e.Items.length;
                e.IsBind=true;
                //执行绑定后操作。
//                for (var i=0,j= 50;i<j;i++) {
//                    i = parseInt(i);
//                    var item = e.Items[i];
//                    if(item == null)
//                         continue;
//                    h.Grid.DolayoutRow(e,i);
//                    if (e.OnRowBinded != null)
//                        e.OnRowBinded(e,item.GetE(),i);
//                }
                h.Grid.DolayoutHeader(e);
                e.contentbox.scrollLeft=e.CurrentScrollLeft;
                e.contentbox.scrollTop = e.CurrentscrollTop;
                e.headerbox.style.display="";
                if(CompletedHandler !=null)
                    CompletedHandler();
                if(e.BindedHandler != null)
                    e.BindedHandler();
        });
    };
    h.Grid.AddItem = function (e, obj) {
        var i = e.Data.length;
        e.Data.push(obj);
        var html="";
        var cb = e.cellborder,rb=e.rowborder;
        var OnMouseOverStr = new h.StringBuilder([_hname , ".Grid.OnItemMouseOver('",e.id,"'," , i , ");"]).ToString();
        var OnMouseOutStr = new h.StringBuilder([_hname , ".Grid.OnItemMouseOut('",e.id,"'," , i , ");"]).ToString();
        var itemclick = "";
        if (e.OnItemClick !="" && typeof (e.OnItemClick) == "string") {
            itemclick = new h.StringBuilder([e.OnItemClick , "('",e.id,"'," , i , ");"]).ToString();
        }
        var OnClickStr = new h.StringBuilder([_hname , ".Grid.OnItemClick('",e.id,"'," , i , ");" , itemclick]).ToString();
        var itemid=e.id+"_contentrow_"+i;
        if(e.OnRowBinding !=null) e.OnRowBinding(e, i);

       var rowe = d.createElement("div");
       rowe.id=itemid;
       rowe.className = e.rowcss;
       var style= "display:block;border-style:solid; border-width: "+rb.top+"px "+rb.right+"px "+rb.bottom+"px "+rb.left+"px; ";
       rowe.setAttribute("style",style);
       h.addEvent(rowe,"click",function(){h.Grid.OnItemClick(e.id,i);});
       h.addEvent(rowe,"mouseover",function(){h.Grid.OnItemMouseOver(e.id,i);});
       h.addEvent(rowe,"mouseout",function(){h.Grid.OnItemMouseOut(e.id,i);});
//        html=html+"<div id='"+itemid+"' class='"+e.rowcss+"' style='display:block;border-style:solid; border-width: "+
//                rb.top+"px "+rb.right+"px "+rb.bottom+"px "+rb.left+"px; ' onclick=\""+OnClickStr+"\" onmouseover =\""+OnMouseOverStr+"\" onmouseout=\""+OnMouseOutStr+"\">";
        var columns = e.columns;
        var columnsE = {};
        columnsE.length=columns.length;
        for(var j = 0,k=columnsE.length;j<k;j++)
        {
            if(columns[j].isshow=="true")
            {
                var cellid=e.id+"_cell_"+i+"_"+j;
                columnsE[j]={};
                columnsE[j].id=cellid;
                columnsE[j].GetE=function(){
                    return  g("#"+this.id,e);
                };
                html =html+ "<div id='"+cellid+"' class='"+e.cellcss+"' style='"+columns[j].data.Style+"float:left;border-style:solid solid solid solid; border-width:"+cb.top+"px "+cb.right+"px "+cb.bottom+"px "+cb.left+"px; height:"+e.rowheight+"px; ' >"+
                    h.GetDataFromTemplet(columns[j].data.templete, i, e.Data)+"</div>";
           }
        }
        //html = html+"<div style='clear: both;'></div></div>";
        html = html+"<div style='clear: both;'></div>";
        rowe.innerHTML = html;
        h.ReInitDom(rowe);
         var refdom = (e.Items.length>0)?e.Items[0].GetE():null;
        e.contentbox.insertBefore(rowe,refdom);
        e.Items[i] = {
            id: itemid,
            ParentObj: e,
            Selected: false,
            GetE: function () {
                return  g("#"+this.id, this.ParentObj);
            },
            Index:i,
            data:obj,
            Items:columnsE
        };
        e.Items.length= e.Items.length+1;
        e.Items.count= e.Items.length;
         if(!e.haveHscroll)
               e.haveHscroll = ((e.contentbox.scrollHeight- e.contentbox.clientHeight)>0)?true:false;
        //当出现滚动条时。重新计算宽度。
        if(e.haveHscroll && !e.rdrawhaveHscrollsE)
        {
           for(var a=0;a<i;a++)
                    h.Grid.DolayoutRow(e,a);
            h.Grid.DolayoutHeader(e);
            e.rdrawhaveHscrollsE=true;
        }
        h.Grid.DolayoutRow(e,i);
        return i;
    };
    h.Grid.InitColumns=function(e){
        if(e.columns != undefined){ return e.columns;}
        var columnsElement = g("h:gridcolumn",e);
        if(columnsElement == null || columnsElement == undefined) return null;
        var columns = {},cb = e.headercellborder,rb = e.headerrowborder;
        columns.headerheight = parseInt(e.headerheight-rb.top-rb.bottom);
        columns.headerrow = {};
        columns.headerrow.id= e.id+"_headerrow";
        columns.html="<div id='"+e.id+"_headertable' style='width:10000px;'>"+
                                    "<div id='"+columns.headerrow.id+"' class='"+e.headerrowcss+"' style='float:left;display:block;border-style:solid;border-width: "+rb.top+"px "+rb.left+"px "+rb.bottom+"px "+rb.right+"px; height:"+columns.headerheight+"px;' >";
        columns.length=columnsElement.length;
        columns.width=0;
        columns.widthauto =new Array();
        columns.widthnotauto = new Array();
        var j = 0;
        for(var i =0,j=columnsElement.length;i<j;i++)
        {
            var gridcolumn=columnsElement[i];
            columns[i]={};
            columns[i].index = i;
            columns[i].width= h.Attr(gridcolumn, "width") ? h.Attr(gridcolumn, "width") : "*";
            columns[i].isautowidth=h.Attr(gridcolumn, "isautowidth") ? h.Attr(gridcolumn, "isautowidth") : "true";
            if(columns[i].width == "*")
            {
                columns[i].isautowidth="true";
            }
            else
            {
                columns[i].isautowidth="false";
            }
            columns[i].isselectedoncick = h.Attr(gridcolumn, "isselectedoncick") ? h.Attr(gridcolumn, "isselectedoncick") : "true";
            columns[i].sortkey = h.Attr(gridcolumn, "sortkey") ? h.Attr(gridcolumn, "sortkey") : "";
            columns[i].isdraging = h.Attr(gridcolumn, "isdraging") ? h.Attr(gridcolumn, "isdraging") : "true";
            columns[i].isshow =h.Attr(gridcolumn, "isshow") ? h.Attr(gridcolumn, "isshow") : "true";
            columns[i].css= h.Attr(gridcolumn, "css") ? h.Attr(gridcolumn, "css") : "gridcolumncss";
            columns[i].minwidth=  parseInt(h.Attr(gridcolumn, "minwidth") ? h.Attr(gridcolumn, "minwidth") : "100");
            columns[i].issortasc = true;
            columns[i].Selected=false;
            columns[i].border = e.headercellborder;
            columns[i].header={};
            var headertempletE = g("h:headertemplet",columnsElement[i])[0]; 
            columns[i].header.templete = headertempletE.innerHTML;
            columns[i].header.Style=headertempletE.style.cssText.Trim(";","") == ""? "":headertempletE.style.cssText.Trim(";","")+";";
            columns[i].header.id=e.id+"_headercell_0_"+i;
            columns[i].header.spliterid=e.id+"_headercellSpliter_0_"+i;
            columns[i].GetE = function(){
                return g("#"+this.header.id,e);
            };
            columns[i].GetSpliterE=function()
            {
                return g("#"+this.header.spliterid,e);
            };
            columns[i].data={};
            var datatempleteE = g("h:datatemplete",columnsElement[i])[0];
            columns[i].data.templete = datatempleteE.innerHTML;
            columns[i].data.Style=datatempleteE.style.cssText.Trim(";","") == ""?"":datatempleteE.style.cssText.Trim(";","") +";";
        }

       return columns;
    };
    h.Grid.InitColumnsHtml=function(e){
       var cb = e.headercellborder,rb = e.headerrowborder;
        var columns=e.columns;
        columns.html="<div id='"+e.id+"_headertable' style='width:10000px;'>"+
                                    "<div id='"+columns.headerrow.id+"' class='"+e.headerrowcss+"' style='float:left;display:block;border-style:solid;border-width: "+rb.top+"px "+rb.left+"px "+rb.bottom+"px "+rb.right+"px; height:"+columns.headerheight+"px;' >";
        columns.widthauto =new Array();
        columns.widthnotauto = new Array();
        var j = 0;
        for(var i =0,j=columns.length;i<j;i++)
        {
            if(columns[i].isshow == "true")
            {
                var dragingstr = "w-resize";
                if(columns[i].isdraging=="false")
                {
                    dragingstr="pointer";
                }
                if(columns[i].isautowidth=="true")
                    columns.widthauto.push(columns[i]);
                else
                    columns.widthnotauto.push(columns[i]);
                var OnMouseOverStr = new h.StringBuilder([_hname , ".Grid.OnHeaderItemMouseOver('",e.id,"'," , i , ");"]).ToString();
                var OnMouseOutStr = new h.StringBuilder([_hname , ".Grid.OnHeaderItemMouseOut('",e.id,"'," , i , ");"]).ToString();
                var OnClickStr = new h.StringBuilder([_hname , ".Grid.OnHeaderItemClick('",e.id,"'," , i , ");"]).ToString();
                 columns[i].html = "<div id='"+columns[i].header.id+"' class='"+e.headercss+"' style='"+columns[i].header.Style+" float:left;border-style:solid; border-width: "+cb.top+"px "+cb.left+"px "+cb.bottom+"px "+cb.right+"px; height:"+(columns.headerheight-cb.top-cb.bottom)+"px;' onmousemove=\""+OnMouseOverStr+"\" onmouseout=\""+OnMouseOutStr+"\" onclick=\""+OnClickStr+"\">"+
                "<div id='"+columns[i].header.spliterid+"' class='spliter_sort_clear' style='float:left; height:"+(columns.headerheight-cb.top-cb.bottom)+"px; width:10px; cursor:"+dragingstr+"; '>&nbsp;</div>"+ columns[i].header.templete+"</div>";
                 columns.html = columns.html+columns[i].html ;
             }
        }
       columns.html = columns.html+"<div style='clear: both;'></div></div><div id='"+e.id+"_headercell_scorll' class='"+e.headerrowcss+"' style='float:left;border-style:solid solid solid solid; border-width: "+cb.top+"px "+cb.left+"px "+cb.bottom+"px "+cb.right+"px; height:"+(e.headerheight-cb.top-cb.bottom)+"px; width:3000px; '>&nbsp;</div></div>";
       e.headerbox.html(columns.html);
    };
    h.Grid.ShowColumns=function(e){
        e.headerbox.style.display="none";
        h.Grid.InitColumnsHtml(e);
        var SelectHanders = h.Grid.GetSelectedHeader(e);
        if(SelectHanders.length>0)
               h.Grid.SelectedHeader(e,SelectHanders[0].index);
        h.Grid.Bind(e,undefined,true,function(){
               e.headerbox.style.display = "";
               if(e.BindedHandler != null)
                    e.BindedHandler(e);
        });
     
    };
    h.Grid.OnHeaderItemMouseOver=function(gridid,i){
            var e = g("#"+gridid);
            if(e ==null || e == undefined || e.columns == undefined)
                return;
            if(e.columns[i].sortkey != "")
            {
                if (e.columns[i].Selected == false)
                    e.columns[i].GetE().className = e.headercsshover;
            }
            if(e.HeaderItemMouseOverHandle !=null && typeof (e.HeaderItemMouseOverHandle) == "function")
            {
                e.HeaderItemMouseOverHandle(e,index,e.columns,e.columns[i].GetE());
            }

    };
    h.Grid.OnHeaderItemMouseOut=function(gridid,i)
    {
            var e = g("#"+gridid);
            if(e.columns == undefined || e.columns == null)
                return;
            if(e.columns[i].sortkey != "")
            {
                if (e.columns[i].Selected == false)
                    e.columns[i].GetE().className = e.headercss;
            }
            if(e.HeaderItemMouseOutHandle !=null  && typeof (e.HeaderItemMouseOutHandle) == "function")
            {
                e.HeaderItemMouseOutHandle(e,index,e.columns,e.columns[i].GetE());
            }
    };
    h.Grid.OnHeaderItemClick=function(id,i)
    {
          var e = g("#"+id);
          if(e == null)
            return;
          var columns = e.columns;
           if(columns == undefined || columns == null)
                return;
        if (columns[i].isselectedoncick == "true" && columns[i].sortkey !="") {
            h.Grid.UnSelectAllHeader(e);
            h.Grid.SelectedHeader(e, i);
            if (e.SortHandle != null && typeof (e.SortHandle) == "function")
                e.SortHandle(e, i,columns,columns[i]);
        }
        if (e.HeaderItemClickHandle != null && typeof (e.HeaderItemClickHandle) == "function")
            e.HeaderItemClickHandle(e, i,columns,columns[i]);
       
    };
    h.Grid.OnItemClick = function (listid, index) {
        var lv = g("#"+listid);
        if(lv == null)
            return;
        var item = lv.Items[index];
        if (lv.isUnSelectedInOnClick == "true") {
            if (item.Selected)
                h.Grid.UnSelect(lv, index);
            else
                h.Grid.Select(lv, index);
        }
        else
            h.Grid.Select(lv, index);
        if(lv.iskeyselect == "true")
        {
            if(lv.isContinueSelect)
            {
                 lv.keyEndSelectIndex=index;
                 h.Grid.ContinueSelect(lv,lv.keyStartSelectIndex,lv.keyEndSelectIndex);
            }
            else
            {
                 lv.keyStartSelectIndex=index;
            }
        }
        if (lv.OnItemClick != null && typeof (lv.OnItemClick) == "function")
            lv.OnItemClick(lv, item.GetE(), index);
    };
    h.Grid.OnItemMouseOver = function (listid, index) {
        var lv = g("#"+listid);
        if(lv ==null || lv == undefined || lv.Items == undefined)
            return;
        try{
            var ItmeE = lv.Items[index].GetE();
            if (lv.Items[index].Selected == false)
                ItmeE.className = lv.rowcsshover;
            if(lv.ItemMouseOverHandle !=null && typeof (lv.ItemMouseOverHandle) == "function")
            {
                var itemdom =  lv.Items[index].GetE();
                lv.ItemMouseOverHandle(lv,index,itemdom);
            }
        }catch(e){}
    };
    h.Grid.OnItemMouseOut = function (listid, index) {
        var lv = g("#"+listid);
        if(lv.Items == undefined || lv.Items == null)
            return;
         try
         {
            var ItmeE = lv.Items[index].GetE();
            if (lv.Items[index].Selected == false)
                ItmeE.className = lv.rowcss;
            if(ItmeE.CustomerRowCss !=undefined && lv.Items[index].Selected == false)
                ItmeE.className = ItmeE.CustomerRowCss;
            if(lv.ItemMouseOutHandle !=null  && typeof (lv.ItemMouseOutHandle) == "function")
            {
                var itemdom =  lv.Items[index].GetE();
                lv.ItemMouseOutHandle(lv,index,itemdom);
            }
        }catch(e){}
    };
    h.Grid.SelectedHeader=function(e,index)
    {
        if (e.columns[index] == undefined)
            return;
        var c = e.columns[index];
        var co = c.GetE();
        var cse=c.GetSpliterE();
        if(cse !=null)
        {
            if(c.sortkey !="")
            {
                if(c.issortasc)
                {
                    cse.className = "spliter_sort_down";
                    c.issortasc=false;
                }
                else
                {
                    cse.className = "spliter_sort_up";
                    c.issortasc=true;
                }
                c.Selected = true;
                co.className = e.headercssactive;
            }
     
            if (e.HeaderSelectChangeHandler != null && typeof (e.HeaderSelectChangeHandler) == "function")
                e.HeaderSelectChangeHandler(e, index,e.columns,co);
        }
    };
    h.Grid.UnSelectedHeader=function(e,i)
    {
        if (e.columns[i] == undefined)
            return;
        var c = e.columns[i];
        var co = c.GetE();
        if(co !=null)
        {
            var cse=c.GetSpliterE();
            cse.className="spliter_sort_clear";
            c.Selected = false;
            co.className = e.headercss;
            if (e.HeaderSelectChangeHandler != null && typeof (e.HeaderSelectChangeHandler) == "function")
                e.HeaderSelectChangeHandler(e, i,e.columns,co);
        }
    };
    h.Grid.GetSelectedHeader=function(e){
        if (e.columns == undefined)
            return;
        var columns=e.columns;
        var ncolumns = new Array();
        for(var i=0,j=columns.length;i<j;i++)
        {
            if(columns[i].Selected)
                ncolumns.push(columns[i]);
        }
        return ncolumns;
    };
    h.Grid.SelectAllHeader=function(e)
    {
        for (var i=0,j=e.columns.length;i<j;i++) {
            h.Grid.SelectedHeader(e, i);
        }
    };
    h.Grid.UnSelectAllHeader=function(e)
    {
        for (var i=0,j=e.columns.length;i<j;i++) {
            h.Grid.UnSelectedHeader(e, i);
        }
    };
    h.Grid.Select = function(e,index)
    {
        if (e.Items[index] == undefined || !e.IsBind)
            return;
        var item = e.Items[index];
        var itemE = item.GetE();
        if(itemE == null) return;
        if (e.ismultiselect === "false") {
            h.Grid.UnSelectAll(e);
        }
        item.Selected = true;
        itemE.className = e.rowcssactive;
        if (e.SelectChangeHandler != null)
            e.SelectChangeHandler(e, index);
   };
    h.Grid.UnSelect = function (e, index) {
        if (e.Items[index] == undefined || !e.IsBind)
            return;
        var item = e.Items[index];
        var obj = item.GetE();
        if(obj == null) return;
        item.Selected = false;
        obj.className = e.rowcss;
        if(obj.CustomerRowCss !=undefined)
            obj.className = obj.CustomerRowCss;
        if (e.SelectChangeHandler != null)
            e.SelectChangeHandler(e, index);
    };
    h.Grid.SelectAll = function (e) {
        for (var i in e.Items) {
            i = parseInt(i);
            h.Grid.Select(e, i);
        }
    };
    h.Grid.UnSelectAll=function(e){
           for (var i in e.Items) {
            i = parseInt(i);
            h.Grid.UnSelect(e, i);
        }
    };
    h.Grid.GetSelect = function (e) {
        var selectDatas = {};
        selectDatas.selectIndexs = {};
        var j = 0;
        for (var i in e.Items) {
            var item = e.Items[i];
            var data = e.Data[i];
            if (item.Selected == true)
            {
                selectDatas[j]={ obj: item, index: parseInt(i)};
                selectDatas.selectIndexs[i]=selectDatas[j];
                j++;
             }
        }
        selectDatas.length = j;
        return selectDatas;
    };
    h.Grid.ContinueSelect=function(e,sIndex,eIndex){
        if(sIndex >=eIndex)
        {
            for(var i=sIndex,j=eIndex;i>=j;i--)
            {
                h.Grid.Select(e,i);
            }
        }
        else
        {
            for(var i=sIndex,j=eIndex;i<=j;i++)
            {
                h.Grid.Select(e,i);
            }
        }
    };
    h.Grid.UpdateItem = function(e,i)
    {
        if (e.OnRowBinding != null)
            e.OnRowBinding(e, i);
        var item = e.Items[i];
        if(item == null || item == undefined)
            return false;
        var itemobj = item.GetE();

        var columns = e.columns;
        for(var j = 0,k=item.Items.length;j<k;j++)
        {
           if(columns[j].isshow == "true")
           {
                var cellobj = item.Items[j].GetE();
                cellobj.html(h.GetDataFromTemplet(columns[j].data.templete, i, e.Data));
           }
        }
        if (e.OnRowBinded != null)
            e.OnRowBinded(e, item, i);
        return true;
    };
    h.Grid.DeleteItem = function (e, index) {
        if (e.Items[index] == null || e.Items[index] ==undefined)
            return false;
        var item = e.Items[index];
        var itemObj = item.GetE();
        if(itemObj == null)
            return false;
        e.contentbox.removeChild(itemObj);
        delete e.Items[index];
        delete e.Data[index];
        return true;
    };
    h.Grid.SetRowCss=function(e,index,css)
    {
        if (e.Items[index] == undefined || !e.IsBind)
            return;
        var item = e.Items[index];
        var itemE = item.GetE();
        if(itemE == null) return;
        itemE.CustomerRowCss=css;
        itemE.className = css;
    };
    //#endregion h:grid
    //#region pagespitter
    h.Defui["h:pagesplitter"] = h.Defui["h:pagesplitter"] || {}; h.PageSplitter = h.Defui["h:pagesplitter"];
    h.PageSplitter.Init = function (e) {
        if (e.id == undefined) { alert("h:pagssplitter is not setting id"); return; }
        e.isInit = true;
        e.tabIndex=0;
        e.PageSize = h.Attr(e, "PageSize") ? h.Attr(e, "PageSize") : "10";
        e.PageSize = parseInt(e.PageSize);
        e.CurrentPage = 0;
        e.Total = h.Attr(e, "Total") ? h.Attr(e, "Total") : "50";
        e.Total = parseInt(e.Total);
        e.PageTotal;
        e.ShowSize = h.Attr(e, "ShowSize") ? h.Attr(e, "ShowSize") : "5";
        e.ShowSize = parseInt(e.ShowSize);
        e.Panel = e;
        e.OnPageChange = null;
        e.ClickHandler = _hname + ".PageSplitter.OnPageItemClick";
        e.GoPageHandler = _hname + ".PageSplitter.OnGoPageClick";
        e.UpPageTxt = "<";
        e.CssUpPage = h.Attr(e, "CssUpPage") ? h.Attr(e, "CssUpPage") : "Item";
        e.NextPageTxt = ">";
        e.CSSNextPage = h.Attr(e, "CSSNextPage") ? h.Attr(e, "CSSNextPage") : "Item";
        e.FirstPage = "|<";
        e.CSSFirstPage = h.Attr(e, "CSSFirstPage") ? h.Attr(e, "CSSFirstPage") : "Item";
        e.EndPage = ">|";
        e.CssEndPage = h.Attr(e, "CssEndPage") ? h.Attr(e, "CssEndPage") : "Item";
        e.CSSPageItem = h.Attr(e, "CSSPageItem") ? h.Attr(e, "CSSPageItem") : "Item";
        e.CSSPage = "";
        e.CSSSelect = h.Attr(e, "CSSSelect") ? h.Attr(e, "CSSSelect") : "Item_hover";
        e.CSSUpNextShow = h.Attr(e, "CSSUpNextShow") ? h.Attr(e, "CSSUpNextShow") : "Item";
        e.CSSGoTxt = h.Attr(e, "CSSGoTxt") ? h.Attr(e, "CSSGoTxt") : "CSSGoTxt";
        e.IsShowGoPanel = h.Attr(e, "IsShowGoPanel") ? h.Attr(e, "IsShowGoPanel") : "true";
        //#region 方法
       e.Bind = function () {
            if (e.Total == undefined) {
                alert("please set Total property");
                return;
            }
            if ((e.Total % e.PageSize) > 0)
                e.PageTotal = parseInt(e.Total / e.PageSize) + 1;
            else
                e.PageTotal = parseInt(e.Total / e.PageSize);
            var showPageTotal = 0;
            if (parseInt(e.PageTotal % e.ShowSize) > 0)
                showPageTotal = parseInt(e.PageTotal / e.ShowSize) + 1;
            else
                showPageTotal = parseInt(e.PageTotal / e.ShowSize);
            var showCurrent = parseInt(e.CurrentPage / e.ShowSize) + 1;
            var showmax = e.ShowSize * showCurrent;
            var showmin = e.ShowSize * (showCurrent - 1);
            if (showmax > e.PageTotal) {
                showmax = e.PageTotal;
            }

            if (e.ShowSize >= e.PageTotal) {
                showmax = e.PageTotal;
            }
            if (e.CurrentPage >= e.PageTotal - 1) {
                e.CurrentPage = e.PageTotal - 1;
            }
            var click = e.ClickHandler + "(\"" + e.id + "\",0);";
            var fiststr = "<div onclick='" + click + "' class='" + e.CSSFirstPage + "' onmouseover=\"this.className='" + e.CSSSelect + "'\" onmouseout=\"this.className='" + e.CSSFirstPage + "'\">" + e.FirstPage + "</div>";
            click = e.ClickHandler + "(\"" + e.id + "\"," + (e.PageTotal - 1) + ");";
            var endstr = "<div onclick='" + click + "' class='" + e.CssEndPage + "' onmouseover=\"this.className='" + e.CSSSelect + "'\" onmouseout=\"this.className='" + e.CssEndPage + "'\">" + e.EndPage + "</div>";
            click = e.ClickHandler + "(\"" + e.id + "\"," + (e.CurrentPage - 1) + ");";
            var upstr = "<div onclick='" + click + "' class='" + e.CssUpPage + "' onmouseover=\"this.className='" + e.CSSSelect + "'\" onmouseout=\"this.className='" + e.CssUpPage + "'\">" + e.UpPageTxt + "</div>";
            click = e.ClickHandler + "(\"" + e.id + "\"," + (e.CurrentPage + 1) + ");";
            var nextstr = "<div onclick='" + click + "' class='" + e.CSSNextPage + "' onmouseover=\"this.className='" + e.CSSSelect + "'\" onmouseout=\"this.className='" + e.CSSNextPage + "'\">" + e.NextPageTxt + "</div>";
            click = e.ClickHandler + "(\"" + e.id + "\"," + (showmin - 1) + ");";
            var uppstr = "<div onclick='" + click + "' class='" + e.CSSUpNextShow + "' onmouseover=\"this.className='" + e.CSSSelect + "'\" onmouseout=\"this.className='" + e.CSSUpNextShow + "'\">...</div>";
            click = e.ClickHandler + "(\"" + e.id + "\"," + showmax + ");";
            var nextpstr = "<div onclick='" + click + "' class='" + e.CSSUpNextShow + "' onmouseover=\"this.className='" + e.CSSSelect + "'\" onmouseout=\"this.className='" + e.CSSUpNextShow + "'\">...</div>";
            var cssSelect = "";
            if (e.CurrentPage == 0) {
                fiststr = "";
                upstr = "";
            }
            if (e.CurrentPage >= e.PageTotal - 1) {
                endstr = "";
                nextstr = "";
            }
            if (showCurrent <= 1) {
                uppstr = "";
            }
            if (showCurrent >= showPageTotal) {
                nextpstr = "";
            }
            var html = "<div id='" + e.id + "pageSplit' class='" + e.CSSPage + "'>" + fiststr + upstr + uppstr;
            for (var i = showmin; i < showmax; i++) {
                if (e.ClickHandler != undefined) {
                    click = e.ClickHandler + "(\"" + e.id + "\"," + i + ");";
                }
                if (e.CurrentPage == i) {
                    cssSelect = e.CSSSelect;
                }
                else {
                    cssSelect = e.CSSPageItem;
                }
                html = html + "<div onclick='" + click + "' class='" + cssSelect + "'  onmouseover=\"this.className='" + e.CSSSelect + "'\" onmouseout=\"this.className='" + cssSelect + "'\">" + (i + 1) + "</div>";
            }
            click = e.GoPageHandler + "(\"" + e.id + "\");";
            var goPanelstr = "<div class='" + e.CSSGoTxt + "' contentEditable=true id='" + e.id + "txt' >" + (e.CurrentPage + 1) + "</div>" + "<div class='" + e.CSSPageItem + "' onclick='" + click + "'  onmouseover=\"this.className='" + e.CSSSelect + "'\" onmouseout=\"this.className='" + e.CSSFirstPage + "'\">GO</div>";
            if (e.IsShowGoPanel === "false") {
                goPanelstr = "";
            }
            html = html + nextpstr + nextstr + endstr;
            html = html + goPanelstr + "<div class='" + e.CSSPageItem + "'>" + (e.CurrentPage + 1) + "/" + e.PageTotal + "</div>" + "</div>";
            e.Panel.innerHTML = html;
        };
        //#endregion 方法
    };
    h.PageSplitter.OnPageItemClick = function (id, i) {
        var e = g("#" + id);
        h.PageSplitter.SetCurrentPage(e, i);
    };
    h.PageSplitter.OnGoPageClick = function (id) {
        h.PageSplitter.GoPage(id);
    };
    h.PageSplitter.SetCurrentPage = function (e, index) {
        e.CurrentPage = index;
        e.Bind();
        if (e.OnPageChange != null)
            e.OnPageChange(e, index);
    };
    h.PageSplitter.GoPage = function (id) {
        var e = g("#" + id);
        var gotext = g("#" + e.id + "txt");
        var regu = /^[-]{0,1}[0-9]{1,}$/;
        if (!regu.test(gotext.innerHTML)) {
            alert("please input num");
            return;
        }
        if (gotext.innerHTML > e.PageTotal) {
            gotext.innerHTML = e.PageTotal;
        }
        h.PageSplitter.SetCurrentPage(e, parseInt(gotext.innerHTML) - 1);
        return parseInt(gotext.innerHTML);
    };
    //#endregion pagesplitter
    //#region editdroplist
    h.Defui["h:editdroplist"] = h.Defui["h:editdroplist"] || {}; h.EditDropList = h.Defui["h:editdroplist"];
    h.EditDropList.Init = function (e) {
        if (e.id == undefined || e.id == "") { h.error("h:editdroplist is not setting id"); }
        e.isInit = true;
        e.Value = h.Attr(e, "Value") ? h.Attr(e, "Value") : "";
        //e.ItemHeight = h.Attr(e, "ItemHeight") ? h.Attr(e, "ItemHeight") : "26";
        //e.ItemHeight = parseInt(e.ItemHeight);
        //e.ItemBorderHeight = h.Attr(e, "ItemBorderHeight") ? h.Attr(e, "ItemBorderHeight") : "10";
        //e.ItemBorderHeight = parseInt(e.ItemBorderHeight);
        e.DropBoxCss = h.Attr(e, "DropBoxCss") ? h.Attr(e, "DropBoxCss") : "DropBoxCss";
        e.DropBoxHeight = h.Attr(e,"DropBoxHeight")?h.Attr(e, "DropBoxHeight") : "260";
        e.DropBoxHeight = parseInt(e.DropBoxHeight);
        e.ItemTemplet = h.Attr(e, "ItemTemplet") ? h.Attr(e, "ItemTemplet") : null; //DropBoxItemTemplet
        if (e.ItemTemplet == null) {
            var t = g("h:ItemTemplet", e)[0];
            if (t == undefined) {
                e.ItemTemplet = "{=[0]}";
            }
            e.ItemTemplet = t.innerHTML;
        }
        e.TextDataTemplet = h.Attr(e, "TextDataTemplet") ? h.Attr(e, "TextDataTemplet") : "{=[0]}";
        e.itemcss = h.Attr(e, "itemcss") ? h.Attr(e, "itemcss") : "itemcss"; //DropBoxItemCssRows
        e.itemcsshover = h.Attr(e, "itemcsshover") ? h.Attr(e, "itemcsshover") : "itemcsshover";
        e.itemselectcss = h.Attr(e, "itemselectcss") ? h.Attr(e, "itemselectcss") : "itemselectcss";
        //e.DropBoxMaxRows = h.Attr(e, "DropBoxMaxRows") ? h.Attr(e, "DropBoxMaxRows") : "10";
        //e.DropBoxMaxRows = parseInt(e.DropBoxMaxRows);
        e.Css = h.Attr(e, "Css") ? h.Attr(e, "Css") : "Css";
        e.CssDropDownBtn = h.Attr(e, "CssDropDownBtn") ? h.Attr(e, "CssDropDownBtn") : "btn";
        e.CssDropDownBtnHover = h.Attr(e, "CssDropDownBtnHover") ? h.Attr(e, "CssDropDownBtnHover") : "btn_hover"; //DropDownBtnMoveCss
        e.DropDownBtnContent = h.Attr(e, "DropDownBtnContent") ? h.Attr(e, "DropDownBtnContent") : "&nbsp;";
        e.Data = null; //DataSource
        e.FilterDataHandle = null;
        e.SelectedHandle=null;//当选中一个时触发
        e.TextIsReadonly = h.Attr(e, "TextIsReadonly") ? h.Attr(e, "TextIsReadonly") : "readonly";
        var txtIsReadOnly = e.TextIsReadonly == "readonly" ? "isreadonly='true'" : "";
        e.DropBoxId = e.id + 'DropBox';
        e.DropBox = null;
        e.TextBoxId = e.id + 'txt';
        e.TextBox = null;
        e.DropDownBtnId = e.id + "Btn";
        e.DropDownBtn = null;
        e.IsSelecting = false;
        e.ListBoxId = e.id + "listview";
        var html = "<div id='" + e.DropBoxId + "' class='" + e.DropBoxCss + "'>" +
                "<h:listview iskeyselect='false' id='" + e.ListBoxId + "' itemcss='" + e.itemcss + "' itemcsshover='" + e.itemcsshover + "' itemselectcss='" + e.itemselectcss + "'><h:itemtemplet>" + e.ItemTemplet + "</h:itemtemplet></h:listview>" +
                "</div>" + "<h:text id='" + e.TextBoxId + "' class='Text' " + txtIsReadOnly + "></h:text><h:btn id='" + e.DropDownBtnId + "' css='" + e.CssDropDownBtn + "' csshover='" + e.CssDropDownBtnHover + "' >" + e.DropDownBtnContent + "</h:btn>";
        e.innerHTML = html;
        h.ReInitDom(e);
        e.ListBox = g("#" + e.ListBoxId);
        e.ListBox.OnItemClick = function (list, item, index) {
            e.TextBox.SetText(h.GetDataFromTemplet(e.TextDataTemplet, index, e.ListBox.Data));
            if(e.SelectedHandle !=null)
                e.SelectedHandle(e);
            e.ScrollTop = e.ListBox.Items[index].GetObj().offsetTop;
            h.EditDropList.ToggleDropBox(e);
        };
        e.DropDownBtn = g("#" + e.DropDownBtnId);
        h.addEvent(e.DropDownBtn, "click", h.EditDropList.OnBtn_Click(e), false);
        e.TextBox = g("#" + e.TextBoxId);
        h.Text.AddEvent(e.TextBox, "focus", h.EditDropList.Text_OnFocus(e));
        h.Text.AddEvent(e.TextBox, "blur", h.EditDropList.Text_OnBlur(e));
        h.Text.AddEvent(e.TextBox, "keydown", h.EditDropList.Text_OnKeyDown(e));
        h.Text.AddEvent(e.TextBox, "keyup", h.EditDropList.Text_OnKeyUp(e));
        e.DropBox = g("#" + e.DropBoxId);
        e.DropBox.style.position = "absolute";
        e.DropBox.style.display = "none";
        e.DropBox.style.overflow = "auto";
        e.DropBox.style.height = e.DropBoxHeight+"px";
        e.tabIndex=0;
        h.addEvent(e.DropBox, "mousemove", h.EditDropList.DropBox_OnMouseOver(e), false);
        h.addEvent(e.DropBox, "mouseout", h.EditDropList.DropBox_OnMouseOut(e), false);
        h.addEvent(e.DropBox,"scroll",function(){
                e.TextBox.txt.focus();
        });
        e.TextBox.SetText(e.Value);
        e.ScrollTop=0;
        //#region 方法
        e.SetWidth=function(w)
        {
            if(w > 30)
            {
                e.TextBox.style.width = (w-26)+"px";
                e.DropBox.style.width=w+"px";
            }
            else
            {
                alert("EditDropList.Width is must > 30");
            }
        };
        e.SetData = function (data) {
            e.Data = data;
        };
        e.Bind=function(data){
          if(data !=null)
                  e.Data = data;
          h.EditDropList.FilterData(e);
          e.DropBox.style.display = "none";
        }
        e.GetSelect = function () {
            var index = h.EditDropList.GetSelectIndexFromText(e);
            if (index == -1)
                return e.ListBox.Data[0];
            return e.ListBox.Data[index];
        };
        e.SetValue = function (value) {
            e.TextBox.SetText(value);
            if(e.SelectedHandle !=null)
              e.SelectedHandle(e);
        };
        e.GetValue = function () {
            return e.TextBox.GetText();
        };
        //#endregion 方法

    };
    h.EditDropList.OnBtn_Click = function (e) {
        return function () {
            e.TextBox.txt.focus();
//            if (e.ListBox.IsBind == false) {
//                h.EditDropList.FilterData(e);
//                return;
//            }
//            if (e.DropBox.style.display == "none")
//            {
//                e.DropBox.style.display = "";
//            }
//            else
//                e.DropBox.style.display = "none";
        };
    };
    h.EditDropList.Text_OnFocus = function (e) {
        return function () {
            var isReadonly = false;
            if(e.TextIsReadonly != "readonly")
            {
                isReadonly = true;
            }

            if(isReadonly)
                e.TextIsReadonly = "readonly";

            h.EditDropList.FilterData(e);
            e.DropBox.style.display = "";
            e.DropBox.scrollTop=e.ScrollTop;

            if(isReadonly)
                e.TextIsReadonly = "";
        }
    };
    h.EditDropList.Text_OnKeyDown = function (e) {
        return function () {
            var eventObj = h.GetEvent();
            if (e.ListBox.IsBind == false) {
                e.ListBox.Data = e.Data;
                e.ListBox.Bind();
            }
            if (eventObj.keyCode == 13) {
                e.DropBox.style.display = "none";
                var cselect = e.ListBox.GetSelect();
                if(cselect!=null)
                    e.TextBox.SetText(h.GetDataFromTemplet(e.TextDataTemplet, cselect[0].index, e.ListBox.Data));
                if(e.SelectedHandle !=null)
                    e.SelectedHandle(e);
            } else if (eventObj.keyCode == h.key.map["DOWNARROW"]) {
                e.DropBox.style.display = "";
                var selecters = e.ListBox.GetSelect();
                var index = selecters.length <= 0 ? 0 : selecters[0].index + 1;
                if(index == e.ListBox.Items.length) return;
                e.ListBox.Select(index);
                e.TextBox.SetText(h.GetDataFromTemplet(e.TextDataTemplet, index, e.ListBox.Data));
                var nextOffsetTop = parseInt(e.ListBox.Items[index].GetObj().offsetTop);
                var itemOffsetTop = index==0 ? 0:parseInt(selecters[0].obj.GetObj().offsetTop);
                var dropboxHeight = parseInt(e.DropBox.style.height);
                //console.log("index=%s,nextOffsetTop=%d,itemOffsetTop=%d,dropboxHeight=%d",index,nextOffsetTop,itemOffsetTop,dropboxHeight);
                e.ScrollTop = nextOffsetTop < dropboxHeight ? 0:nextOffsetTop-(dropboxHeight - (nextOffsetTop-itemOffsetTop));
                e.DropBox.scrollTop=e.ScrollTop;

            } else if (eventObj.keyCode == h.key.map["UPARROW"]) {
                e.DropBox.style.display = "";
                selecters = e.ListBox.GetSelect();
                index = selecters.length <= 0 ? 0 : selecters[0].index - 1;
                if(index < 0) return;
                e.ListBox.Select(index);
                e.TextBox.SetText(h.GetDataFromTemplet(e.TextDataTemplet, index, e.ListBox.Data));
                var nextOffsetTop = parseInt(e.ListBox.Items[index].GetObj().offsetTop);
                var itemOffsetTop = parseInt(selecters[0].obj.GetObj().offsetTop);
                var dropboxHeight = parseInt(e.DropBox.style.height);
                e.ScrollTop = itemOffsetTop <= dropboxHeight ? 0:itemOffsetTop-dropboxHeight;
                e.DropBox.scrollTop = e.ScrollTop;

            }
            h.StopEvent();
        };
      
    };
    h.EditDropList.Text_OnKeyUp = function (e) {
        return function () {
            var eObj = h.GetEvent();
            if (eObj.keyCode == h.key.map["DOWNARROW"] || eObj.keyCode == h.key.map["UPARROW"])
                return;
            if(eObj.keyCode == h.key.map["ENTER"])
            {
                 e.DropBox.style.display = "none";
            }
            h.EditDropList.FilterData(e);
            h.StopEvent();
        };
    };
    h.EditDropList.Text_OnBlur = function (e) {
        return function () {
            if (e.IsSelecting == false)
                e.DropBox.style.display = "none";
        };
    };
    h.EditDropList.DropBox_OnMouseOver = function (e) {
        return function () {
            e.IsSelecting = true;
        };
    };
    h.EditDropList.DropBox_OnMouseOut = function (e) {
        return function () {
            e.IsSelecting = false;
        };
    };
    h.EditDropList.ToggleDropBox = function (e) {
        if (e.DropBox.style.display == "none")
            e.DropBox.style.display = "";
        else
            e.DropBox.style.display = "none";
        e.DropBox.scrollTop=e.ScrollTop;
    };
    h.EditDropList.FilterData = function (e) {
        var value = e.TextBox.GetText();
        var reg = new RegExp(value,"ig");
        var dataArr = new Array();

        if (e.TextIsReadonly == "readonly") {
            dataArr = e.Data;
        }
        else {
            if (e.FilterDataHandle == null ) {
                var j = 0;
                if (e.Data != null) {
                    for (var i = 0; i < e.Data.length; i++) {
                        var data = h.GetDataFromTemplet(e.TextDataTemplet, i, e.Data);
                        if (data.match(reg)) {
                            dataArr[j] = e.Data[i];
                            j = j + 1;
                        }
                    }
                }
            }
            else
                dataArr = e.FilterDataHandle(value);
        }

        //this.BindListBox(dataArr);
        e.ListBox.IsBind = false;
        e.ListBox.Data = dataArr;
        e.ListBox.Bind(dataArr,true,function(){
            var height = parseInt(e.ListBox.clientHeight);
            var maxHeight = e.DropBoxHeight;
            if (height < maxHeight) {
                e.DropBox.style.height = height + "px";
                e.DropBox.style.overflow = "hidden";
            }
            else {
                e.DropBox.style.height = maxHeight+ "px";
                e.DropBox.style.overflow = "auto";
            }
            var index = h.EditDropList.GetSelectIndexFromText(e);
            index = index == -1 ? 0 : index;
            if(index < 0) return ;
            e.ListBox.Select(index);
            //e.DropBox.style.display = "";
            e.ScrollTop = index == 0 ?0:e.ListBox.Items[index].GetObj().offsetTop;
            e.DropBox.scrollTop=e.ScrollTop;
            e.ListBox.IsBind = true;
            //console.log("FilterData"); 
        });
    };
    h.EditDropList.GetSelectIndexFromText = function (e) {
        var lv = e.ListBox;
        var value = e.TextBox.GetText();
        for (var key in lv.Data) {
            var index = parseInt(key);
            if (value == h.GetDataFromTemplet(e.TextDataTemplet, index, lv.Data)) {
                return index;
            }
        }
        return -1;
    };
 


    //#endregion editdroplist
    //#region treeview
    h.Defui["h:treeview"] = h.Defui["h:treeview"] || {}; h.TreeView = h.Defui["h:treeview"];
    h.TreeView.Init = function (e) {
        if (e.id == undefined || e.id == "") { h.error("h:treeview is not setting id"); }
        e.isInit = true;
        e.tabIndex=0;
        e.key = h.Attr(e, "key") ? h.Attr(e, "key") : "{=[0]}"; //数据中的唯一标识数据模板
        e.text = h.Attr(e, "text") ? h.Attr(e, "text") : "{=[1]}"; //显示在树中每一项的文本标签数据模板
        e.value = h.Attr(e, "value") ? h.Attr(e, "value") : "{=[0]}"; //点击或选择时的获取到的数据模板
        e.parentid = h.Attr(e, "parentid") ? h.Attr(e, "parentid") : "{=[2]}"; //上一组key数据模板
        e.path = h.Attr(e, "path") ? h.Attr(e, "path") : "{=[3]}"; //当前项的路径格式如|-1|2|3|
        e.icoImg = h.Attr(e, "icoImg") ? h.Attr(e, "icoImg") : "&nbsp;";
        e.isshowico = h.Attr(e, "isshowico") ? h.Attr(e, "isshowico") : "true"; //是否显示图标
        e.isajax = h.Attr(e, "isajax") ? h.Attr(e, "isajax") : "false"; //是否启用AJAX
        e.expandlayer = h.Attr(e, "expandlayer") ? h.Attr(e, "expandlayer") : "10000"; //初始展多少层,默认展开10000层
        e.ismultiselect = h.Attr(e, "ismultiselect") ? h.Attr(e, "ismultiselect") : "false";
        e.itemcss = h.Attr(e, "itemcss") ? h.Attr(e, "itemcss") : "itemcss";
        e.itemcss_hover = h.Attr(e, "itemhovercss") ? h.Attr(e, "itemhovercss") : "itemcss_hover";
        e.itemcss_selected = h.Attr(e, "itemselectedcss") ? h.Attr(e, "itemselectedcss") : "itemcss_selected";
        e.expandlayer = parseInt(e.expandlayer);
        e.SelectingChangeHandler=null;
        e.SelectedChangeHandler=null;
        e.listBindNum = 0;
        e.listviewNum = 0;
        e.preSelectedKey=null;
        e.OnExpandHandle = null;
        e.OnItemClickHandle = null; //单击每一项时触发的事件
        e.OnItemMouseUpHandle = null;
        e.innerHTML = h.TreeView.GetTempletHtml(e);
        h.InitDom(e);
        e.ListBox = g("#" + e.id + "list1");
        e.ListBox.OnRowBinded = h.TreeView.ListView_OnRowBinded(e);
        e.Data = new Array();
        e.TreeViewData = new Array();
      
        e.ConcatArrayData = function (datas) {
            if (!h.isArray(datas)) {
                alert(e.id + "datas is not Array");
                return;
            }
            var j = this.Data.length;
            for (var i = datas.length; i--;) {
                var key = h.GetDataFromTemplet(e.key, i,datas);
                var parentId = h.GetDataFromTemplet(e.parentid, i, datas);
                this.Data[j] = key;
               datas[i].Selected=false;
               datas[i].Index =j;
               datas[i].ParentKey=parentId;
               datas[i].Key=key;
               if(e.TreeViewData[key] == undefined)
                    e.TreeViewData[key] = datas[i];
               else
               {
                    if(e.TreeViewData[key].next !=undefined)
                    {
                       datas[i].next =  e.TreeViewData[key].next;
                       e.TreeViewData[key]= datas[i];
                    }
               }
               if(parentId == -1)
               {
                    e.TreeViewData.next = (e.TreeViewData.next== null || e.TreeViewData.next ==undefined) ? new Array():e.TreeViewData.next;
                    e.TreeViewData.next.push(datas[i]);
                }
                else
                {
                       e.TreeViewData[parentId]=e.TreeViewData[parentId]==undefined ? new Array() : e.TreeViewData[parentId];
                       e.TreeViewData[parentId].next= e.TreeViewData[parentId].next==undefined ? new Array():e.TreeViewData[parentId].next;
                       e.TreeViewData[parentId].next.push(datas[i]);
                }
                j++;
            }
        };
        //#region 方法
        e.SetData = function (datas) {
            this.ConcatArrayData(datas);
        };
        e.Expand = function (CompletedHandler) {
            var listDatas = h.TreeView.GetItemDatas(e, -1);
            e.ListBox.Data = listDatas;
            e.listBindNum=e.listBindNum+1;
            e.ListBox.Bind(listDatas,true,function(){
                e.listBindNum=e.listBindNum-1;
            });
            var waitCompeted = function(){
                if( e.listBindNum==0)
                {
                     if(CompletedHandler !=null)
                           CompletedHandler(e);
                }
                else
                {
                    setTimeout(waitCompeted,200);
                }
            };
            setTimeout(waitCompeted,200);
        };
        e.Selected = function (key) {
            var item = e.TreeViewData[key];
            var isselectchange= true;
            if(e.SelectingChangeHandler !=null)
                isselectchange=e.SelectingChangeHandler(e,item);
            if(isselectchange)
            {
                var titleobj = g("#" + e.id + "_" + key + "_title");
                var checks = g("INPUT",titleobj);
                if(item.Selected !=true)
                {
                    if(checks !=null && checks[0]!=null)
                    {
                        checks[0].checked=true;
                    }
                    titleobj.className = e.itemcss_selected;
                    titleobj.Selected = true;
                    item.Selected = true;
                }
                if(e.SelectedChangeHandler !=null)
                    e.SelectedChangeHandler(e,key,item);
            }
        };
        e.Selecteds = function(key)
       {
            e.Selected(key);
            if(e.TreeViewData[key].next !=undefined && e.TreeViewData[key].next.length >0)
            {
               for(var len = e.TreeViewData[key].next.length;len--;)
               {
                   var item = e.TreeViewData[key].next[len];
                    var itemkey =  h.GetDataFromTemplet(e.key,len,e.TreeViewData[key].next);
                    e.Selecteds(itemkey);
               }
            }
        };
        e.UnSelected = function (key) {
            var item = e.TreeViewData[key];
            var isselectchange= true;
            if(e.SelectingChangeHandler !=null)
                isselectchange=e.SelectingChangeHandler(e,item);
            if(isselectchange)
            {
                var titleobj = g("#" + e.id + "_" + key + "_title");
                var checks = g("INPUT",titleobj);
                if(item.Selected !=false)
                {
                    if(checks !=null && checks[0]!=null)
                    {
                        checks[0].checked=false;
                    }
                    titleobj.className = e.itemcss;
                    titleobj.Selected = false;
                    item.Selected = false;
                }
                if(e.SelectedChangeHandler !=null)
                    e.SelectedChangeHandler(e,key,item);
            }
        };
        e.UnSelecteds = function(key)
        {
            e.UnSelected(key);
            if(e.TreeViewData[key].next !=undefined && e.TreeViewData[key].next.length >0)
            {
               for(var len = e.TreeViewData[key].next.length;len--;)
               {
                    var item = e.TreeViewData[key].next[len];
                    var itemkey =  h.GetDataFromTemplet(e.key,len,e.TreeViewData[key].next);
                    e.UnSelecteds(itemkey);
               }
            }
        };
        e.SelectedAll = function () {
            for (var i = 0,j=e.Data.length; i < j; i++) {
                var key =e.Data[i];
                e.Selected(key);
            }
        };
        e.UnSelectedAll = function () {
            for (var i = 0,j=e.Data.length; i < j; i++) {
                var key =e.Data[i];
                 e.UnSelected(key);
            }
        };
        e.GetSelectedObjs = function(callback)
        {
            var datas = new Array();
            for(var i = e.Data.length;i--;)
            {
                var data = e.TreeViewData[e.Data[i]];
                if(data.Selected)
                {
                    if(callback !=null)
                        callback(data);
                    datas.push(data);
                }
            }
            return datas;
        }
        //#endregion 方法

    };
    h.TreeView.GetTempletHtml = function (e) {
        e.listviewNum = e.listviewNum + 1;
        var listviewid = e.id + "list" + e.listviewNum;
        var itemid = e.id + "_" + e.key + "_";
        var titleid = itemid + "title";
        var contentid = itemid + "content";
        var expandbtnid = itemid + "expandbtn";
        var icoid = itemid + "ico";
        var labelid = itemid + "label";
        var Expandbtn_OnClickStr = _hname + ".TreeView.ExpandBtn_OnClick(this,\"" + contentid + "\");";
        var inputCheckHtml = "<INPUT TYPE=checkbox />&nbsp;";
        if(e.ismultiselect=="false")
            inputCheckHtml="";
        var html = "<h:listview iskeyselect='false' id='" + listviewid + "'>" +
                                "<h:itemtemplet>" +
                                    "<div id='" + titleid + "' class='" + e.itemcss + "'>" +
                                    "<h:btn id='" + expandbtnid + "' css='ExpandBtn' csshover='ExpandBtn_hover' cssactive='ExpandBtn_active' cssactivehover='ExpandBtn_active_hover' onclick='" + Expandbtn_OnClickStr + "'>&nbsp;</h:btn>";
        if (e.isshowico === "true")
            html = html + "<h:btn id='" + icoid + "' css='ico' csshover='ico_hover' cssactive='ico_loading' cssactivehover='ico_loading'>&nbsp;&nbsp;" + e.icoImg + "</h:btn>";
        html = html + "<div id='" + labelid + "' class='label' >"+inputCheckHtml + e.text + "</div></div>" +
                                    "<div id='" + contentid + "' style='padding-left:16px;'></div>" +
                                "</h:itemtemplet>" +
                            "</h:listview>";
        return html;
    };
    h.TreeView.GetItemDatas = function (e, pid) {
       if(pid == -1)
            return e.TreeViewData.next;
       var data = e.TreeViewData[pid];
       if(data == null || data == undefined)
            return null;
       return data.next;
    };
    h.TreeView.ListView_OnRowBinded = function (e) {
        return function (lv, item, i) {
            var listviewid = lv.id;
            var id = h.GetDataFromTemplet(e.key, i, lv.Data);
            var path = h.GetDataFromTemplet(e.path, i, lv.Data);
            var layernum = h.TreeView.GetLayerNum(path) - 2;
            var itemid = e.id + "_" + id + "_";
            var titleid = itemid + "title";
            var contentid = itemid + "content";
            var expandbtnid = itemid + "expandbtn";
            var icoid = itemid + "ico";
            var labelid = itemid + "label";
            var ExpandBtn = g("#" + expandbtnid);
            var content = g("#" + contentid);
            var ico = g("#" + icoid);
            var titleObj = g("#" + titleid);
            var labelObj = g("#" + labelid);
            titleObj.Selected = false;
            content.innerHTML = h.TreeView.GetTempletHtml(e);
            h.InitDom(content);
            listviewid = e.id + "list" + e.listviewNum;
            var listview = g("#" + listviewid);
            listview.OnRowBinded = h.TreeView.ListView_OnRowBinded(e);
            var args = { TreeView: e, ListView: lv, ExpandBtn: ExpandBtn, Content: content, Datas: datas, DownListView: listview, Id: id, Icobtn: ico };
            h.addEvent(ExpandBtn, "click", h.TreeView.ExpandBtn_OnClick(args), false);
            args = { Sender: titleObj, TreeView: e };
            h.addEvent(titleObj, "mouseover", h.TreeView.Item_MouseOver(args), true);
            h.addEvent(titleObj, "mouseout", h.TreeView.Item_MouseOut(args), true);
            h.addEvent(titleObj, "mouseup", h.TreeView.Item_OnMouseUp(args), true);

            args = { Sender: labelObj, TreeView: e, ListView: lv, Index: i, Title: titleObj };
            h.addEvent(labelObj, "click", h.TreeView.Item_LabelOnClick(args), true);

           
            if (e.isajax != "true") {
                 var datas = h.TreeView.GetItemDatas(e, id);
                if (h.isArray(datas)) {
                    listview.Data = datas;
                    e.listBindNum=e.listBindNum+1;
                    listview.Bind(datas,true,function(){
                    e.listBindNum=e.listBindNum-1;
                    });
                }
            }
            if (layernum > e.expandlayer) {
                content.style.display = "none";
                ExpandBtn.Active("false");
            }
            else {
                if (e.isajax == "true") {
                    var datas = undefined;
                    ico.Active("true");
                    if (e.OnExpandHandle != null)
                        datas = e.OnExpandHandle(id, function () {
                           ico.Active("false");
                        }, listview, content);
                    if (h.isArray(datas)) {
                        e.ConcatArrayData(datas);
                        datas = h.TreeView.GetItemDatas(e, id);
                        listview.Data = datas;
                        e.listBindNum=e.listBindNum+1;
                        listview.Bind(datas,false,function(){
                             e.listBindNum=e.listBindNum-1;
                             listview.IsBind == true ? ExpandBtn.Active("true") : ExpandBtn.Active("false");
                        });
                    }
                }
            }
            if (datas == undefined || datas.length <= 0) {
                    content.style.display = "none";
                    e.isajax == "true" ? ExpandBtn.Active("false") : ExpandBtn.Active("true");
            }
            else
            {
                 if(content.style.display == "")
                    ExpandBtn.Active("true");
                else
                    ExpandBtn.Active("false");
            }
        };
    };
    h.TreeView.ExpandBtn_OnClick = function (args) {
        return function () {
            //var content = g("#" + contentid);
            var content = args.Content;
            var ExpandBtn = args.ExpandBtn;
            var treeview = args.TreeView;
            var listview = args.DownListView;
            var ico = args.Icobtn;
            if (treeview.isajax != "true") {
                if (listview.Data == null || listview.Data.length <= 0)
                    return;
                if (ExpandBtn.isactive === "true") {
                    ExpandBtn.Active("false");
                    content.style.display = "none";
                }
                else {
                    ExpandBtn.Active("true");
                    content.style.display = "";
                }
            }
            else {
                var datas = undefined;
                var isdo = false;
                var isasyn = false;
                if (listview.IsBind == false) {
                    if (treeview.OnExpandHandle != null) {
                        ico.Active("true");
                        datas = treeview.OnExpandHandle(args.Id, function () {
                            ico.Active("false");
                        }, listview, content);
                        if (datas == null)
                            isasyn = true;
                        isdo = true;
                    }
                    if (h.isArray(datas)) {
                        treeview.ConcatArrayData(datas);
                        listview.Data = datas;
                        e.listBindNum=e.listBindNum+1;
                        listview.Bind(datas,true,function(){
                            e.listBindNum=e.listBindNum-1;
                        });
                    }
                }
                else {
                    isdo = true;
                }
                if (listview.Data == undefined || listview.Data.length <= 0) {
                    if (isdo) {
                        ExpandBtn.Active("true");
                        content.style.display = "none";
                    }
                    if (isasyn) {
                        ExpandBtn.Active("true");
                        content.style.display = "";
                    }
                    return;
                }
                if (ExpandBtn.isactive === "true") {
                    ExpandBtn.Active("false");
                    content.style.display = "none";
                }
                else {
                    ExpandBtn.Active("true");
                    content.style.display = "";
                }
            }
        };
    };
    h.TreeView.Item_MouseOver = function (args) {
        return function () {
            if (args.Sender.Selected)
                args.Sender.className = args.TreeView.itemcss_selected;
            else
                args.Sender.className = args.TreeView.itemcss_hover;
        };
    };
    h.TreeView.Item_MouseOut = function (args) {
        return function () {
            if (args.Sender.Selected)
                args.Sender.className = args.TreeView.itemcss_selected;
            else
                args.Sender.className = args.TreeView.itemcss;
        };
    };
    h.TreeView.Item_LabelOnClick = function (args) {
        return function () {
            var tree = args.TreeView;
            var value = h.GetDataFromTemplet(tree.value, args.Index, args.ListView.Data);
            var key = h.GetDataFromTemplet(tree.key, args.Index, args.ListView.Data);
            if (args.Title.Selected) {
                if (tree.ismultiselect == "false") {
                       tree.UnSelected(key);
                }
                else
                       tree.UnSelecteds(key);
            }
            else {
                if (tree.ismultiselect == "false") {
                    if(tree.preSelectedKey !=null)
                         tree.UnSelected(tree.preSelectedKey);
                   tree.Selected(key);
                    tree.preSelectedKey=key;
                }
                else {
                    //h.TreeView.Selected(tree, key);
                    tree.Selecteds(key);
                }
            }
            if (args.TreeView.OnItemClickHandle != null) {
                args.TreeView.OnItemClickHandle(value,tree,key);
            }
        };
    };
    h.TreeView.Item_OnMouseUp = function (args) {
        return function () {
            var tree = args.TreeView;
            if (tree.OnItemMouseUpHandle != null) {
                tree.OnItemMouseUpHandle();
            }
        };
    };
    h.TreeView.GetLayerNum = function (path) {
        var data = path.split("|");
        return data.length;
    };
    h.TreeView.EditLabel = function(e,key,text){
            var item = e.TreeViewData[key];
            var labelobj = h.TreeView.GetLabelObj(e,key);
            labelobj.innerHTML = text;
    };
    h.TreeView.GetLabelObj = function(e,key){
        return  g("#" + e.id + "_" + key + "_label");
    };
    //#endregion treeview
    //#region 滚动横幅
    h.Defui["rollbaner"] =h.Defui["h:rollbaner"] || {};h.RollBaner=h.Defui["rollbaner"];
    h.RollBaner.Init=function(e){
          if (e.id == undefined || e.id == "") { h.error("h:RollBaner is not setting id"); }
          e=g("#"+e.id);
          e.isInit = true;
          e.time=h.Attr(e, "time") ? h.Attr(e, "time") : "15000";
          e.width=h.Attr(e, "width") ? h.Attr(e, "width") : "1024";
          e.height=h.Attr(e, "height") ? h.Attr(e, "height") : "200";
          e.time = parseInt(e.time);
          e.CurrentIndex = -1;
          e.Data=null;
          e.style.position="relative";
          e.style.width= e.width;
          e.style.height=e.height;
          e.html(
          "<div id='"+e.id+"_leftbtn' style='position:absolute;' class='leftbtn'></div>"+
          "<div id='"+e.id+"_rightbtn' style='position:absolute;' class='rightbtn'></div>"+
          "<div id='"+e.id+"_Content' class='content' style='width:"+ e.width+"px;height:"+e.height+"px;'></div>");
          e.Content = g("#"+e.id+"_Content");
          e.LeftBtn =g("#" +e.id+"_leftbtn");
          e.LeftBtn.style.position="absolute";
          e.LeftBtn.style.top = (e.height/2)+"px";
          e.LeftBtn.style.left="0px";
          h.addEvent(e.LeftBtn,"click",function(){
                h.RollBaner.Previous(e);
          });
          e.RightBtn = g("#" +e.id+"_rightbtn");
          e.RightBtn.style.position="absolute";
          e.RightBtn.style.top= (e.height/2)+"px";
          e.RightBtn.style.left= (e.width)+"px";
          h.addEvent(e.RightBtn,"click",function(){
                h.RollBaner.Next(e);
          });
    };
    h.RollBaner.SetData=function(e,data)
    {
        e.Data=data;
    };
    h.RollBaner.GetCurrentIndex=function(e)
    {
         if(e.CurrentIndex <0)  
            e.CurrentIndex = e.Data.length-1;
         else if(e.CurrentIndex >e.Data.length-1)
            e.CurrentIndex = 0;
         return e.CurrentIndex;
    };
    h.RollBaner.Previous = function(e)
    {
        e.CurrentIndex =e.CurrentIndex-1;
        index = h.RollBaner.GetCurrentIndex(e);
        e.Content.html(e.Data[index]);
    };
    h.RollBaner.Next=function(e){
        e.CurrentIndex =e.CurrentIndex+1;
        index = h.RollBaner.GetCurrentIndex(e);
        e.Content.html(e.Data[index]);
    };
    h.RollBaner.Show=function(e,index){
        e.CurrentIndex =index;
        index = h.RollBaner.GetCurrentIndex(e);
        e.Content.html(e.Data[index]);
    };
    h.RollBaner.Start=function(e)
    {
       h.RollBaner.Next(e);
       _h.AddInterval(e.id+"_interval",function(){h.RollBaner.Next(e);},e.time);
    };
    h.RollBaner.Stop=function(e)
    {
        h.ClearInterval(e.id+"_interval");
    };
    //#endregion 滚动横幅
    //#region menu 菜单控件
    h.Defui["h:menu"] = h.Defui["h:menu"] || {}; h.Menu = h.Defui["h:menu"];
    h.Menu.Init = function (e) {
          if (e.id == undefined || e.id == "") { h.error("h:menu is not setting id"); }
          e.isInit = true;
          e.Data = {};
          e.Data.next=new Array();
          e.Data.length=0;
      
          e.Data.keyid=e.id;
          e.type= h.Attr(e, "type") ? h.Attr(e, "type") : "popup"; //为popup 右单菜单 main 为普通菜单
          e.submenuwidth= h.Attr(e, "submenuwidth") ? h.Attr(e, "submenuwidth") : "200"; //子菜单宽度
          e.Data.submenuwidth=parseInt(e.submenuwidth);
          h.Menu.initData(e);
          e.innerHTML = "<div id='"+e.id+"_root' class='"+e.type+"'></div>";
          e.Data.GetContentDom=function(){return g("#"+e.id+"_root");};
          e.Data.GetItemDom = function(){return e;};
          e.Data.GetPanelDom = function(){return e;};
          e.hidstacks=  new Array();
          //#region 方法
          if(e.type == "main")
          {
                
                e.Bind = function(){
                   e.BindMainMenu(e.Data);
                };
          }
          if(e.type == "popup")
          {
                e.style.position="absolute";
                e.Bind = function(){
                      e.BindItemMenu(e.Data);
                };
          }
          e.BindItemMenu = function(itemData){
                var data=itemData.next;
                if(itemData.isBind) return ;
                var itemcontentdom = itemData.GetContentDom();
                for(var i=0;i<data.length;i++)
                {
                    var item = d.createElement("h:btn");
                    item.id=data[i].key;
                    item.style.width="100%";
                    item.style.position="relative";
                    var pico = data[i].next.length>0?"&#52;":"";
                    item.innerHTML = "<div class='"+data[i].icocss+"' style='float:left;width:25px;height:20px;line-height: 20px;'  id='"+item.id+"_ico'></div><div style='float:left;' class='itemtext' id='"+item.id+"_text'>"+data[i].itemtemplet+"</div><div id='"+item.id+"_pico' style='float:right;font-family: Webdings;width:20px;height:20px;line-height: 23px;text-align:center;'>"+pico+"</div><div id='"+item.id+"_content' class='itemcontent' style='position:absolute; top:0px;display:none;width:"+itemData.submenuwidth+"px;' ></div>";
                    itemcontentdom.appendChild(item);
                    var br=d.createElement("br");
                    itemcontentdom.appendChild(br);
                    if(data[i].addhr == "true")
                    {
                        var hr=d.createElement("hr");
                        itemcontentdom.appendChild(hr);
                     }
                    data[i].GetContentDom=function(){return g("#"+this.key+"_content");};
                    data[i].GetItemDom = function(){return g("#"+item.id);};
                    data[i].GetPanelDom = function(){return itemData.GetContentDom();};
                    h.Btn.Init(item);
                    h.InitDom(item);
                    if(data[i].ClickHandler !=null)
                        h.addEvent(item,"click",data[i].ClickHandler);
                    if(itemData.key != e.Data.key)
                    {
                        var content = itemData.GetContentDom();
                        var panel = itemData.GetPanelDom();
                        var width = (panel.style.width == "") ? parseInt(panel.clientWidth)-4 : parseInt(panel.style.width)+2;
                        content.style.marginLeft =width+"px";
                    }
                    item.MouseOverHandler=h.Menu.OnMouseOver(e);
                }
                itemData.isBind=true;
          };
          e.BindMainMenu=function(itemData){
                var data=itemData.next;
                if(itemData.isBind) return ;
                var itemcontentdom = itemData.GetContentDom();
                for(var i=0;i<data.length;i++)
                {
                    var item = d.createElement("h:btn");
                    item.id=data[i].key;
                    item.style.position="relative";
                    var pico = data[i].next.length>0?"&#52;":"";
                    item.innerHTML = "<div class='"+data[i].icocss+"' style='float:left;width:25px;height:20px;line-height: 20px;display:none;'  id='"+item.id+"_ico'></div><div style='float:left;' class='itemtext' id='"+item.id+"_text'>"+data[i].itemtemplet+"</div><div id='"+item.id+"_pico' style='float:right;display:none;font-family: Webdings;width:20px;height:20px;line-height: 23px;text-align:center;'>"+pico+"</div><div id='"+item.id+"_content' class='itemcontent' style='position:absolute; top:0px;left:0px;display:none;width:"+itemData.submenuwidth+"px;' ></div>";
                    itemcontentdom.appendChild(item);
                    data[i].GetContentDom=function(){return g("#"+this.key+"_content");};
                    data[i].GetItemDom = function(){return g("#"+item.id);};
                    data[i].GetPanelDom = function(){return itemData.GetContentDom();};
                    h.Btn.Init(item);
                    h.InitDom(item);
                     if(data[i].ClickHandler !=null)
                        h.addEvent(item,"click",data[i].ClickHandler);
                    var content = data[i].GetContentDom();
                    content.style.top=(parseInt(itemcontentdom.clientHeight))+"px";
                    content.style.left =(-parseInt(itemcontentdom.clientWidth)+3)+"px";
                    content.style.zIndex=0;
                    item.MouseOverHandler=h.Menu.OnMouseOver(e);
                }
                itemData.isBind=true;
          };
          e.ShowSubMenu=function(itemData){
                if(itemData.next.length <=0)
                {
                    h.Menu.HidStacksMenuByitemData(e,itemData);
                    return;
                } 
                e.BindItemMenu(itemData);
                var content = itemData.GetContentDom();
                var panel = itemData.GetPanelDom();
                panel.style.display="";
                content.style.display="";
                itemData.isShow=true;
                h.Menu.HidStacksMenuByitemData(e,itemData);
                e.hidstacks.push(itemData);
               


          };
          e.HidSubMenu=function(itemData){
                var content = itemData.GetContentDom();
                content.style.display="none";
                itemData.isShow=false;
          };
          e.SetEventFun = function(key,fn)
          {
                var key =  e.id+"_"+key;
                e.Data[key].ClickHandler = fn;
          };
          //#endregion 方法
    };
    //隐藏同级已显示的下级菜单
    h.Menu.HidStacksMenuByitemData = function(e,itemData){
        var hidmenu =  e.hidstacks.pop();
        var temp = new Array();
        while(hidmenu!=undefined)
        {
            if(itemData.keyid.indexOf(hidmenu.keyid) == -1)
                e.HidSubMenu(hidmenu);
            else
                temp.push(hidmenu);
            hidmenu =  e.hidstacks.pop();
        }
        e.hidstacks=temp;
    };
    //隐藏所有已显示的下级菜单
    h.Menu.HidStacksMenu=function(e)
    {
        var hidmenu =  e.hidstacks.pop();
        while(hidmenu!=undefined)
        {
            e.HidSubMenu(hidmenu);
            hidmenu =  e.hidstacks.pop();
        }
    };
    h.Menu.initData = function(e){
         h.Menu.RecursionData(e,e,e.Data.next);
    };
    h.Menu.RecursionData=function(e,dom,nextData){
         var edatas = g(">h:menuitem",dom);
         for(var i=0,j=edatas.length;i<j;i++)
         {
            var key = h.Attr(edatas[i], "key") ? e.id+"_"+h.Attr(edatas[i], "key"):alert(e.id+" h:menuitem is not setting.");
            var submenuwidth= h.Attr(edatas[i], "submenuwidth") ? h.Attr(edatas[i], "submenuwidth") : "200"; //子菜单宽度
            var itemtemplet = h.Attr(edatas[i], "itemtemplet") ? h.Attr(edatas[i], "itemtemplet"):"";
            var addhr = h.Attr(edatas[i], "addhr") ? h.Attr(edatas[i], "addhr"):"false";
            if(itemtemplet=="")
            {
                var elt =g(">h:itemtemplet",edatas[i]);
                itemtemplet =(elt!=null && elt.length>0)?elt[0].html():"";
            }
            var icocss = h.Attr(edatas[i], "icocss") ? h.Attr(edatas[i], "icocss"):"";
            var data={};
            data.key=key;
            data.keyid=dom.id+"_"+i;
            edatas[i].id=data.keyid;
            data.itemtemplet = itemtemplet;
            data.submenuwidth=parseInt(submenuwidth);
            data.next=new Array();
            data.icocss=icocss;
            data.isBind=false;
            data.isShow=false;
            data.addhr=addhr;
            data.ClickHandler=null;
            e.Data[key] =data;
            e.Data.length++;
            nextData.push(data);
            var nextedatas= g(">h:menuitem",edatas[i]);
            if(nextedatas.length >0)
                h.Menu.RecursionData(e,edatas[i],e.Data[key].next);
         }

    };
    h.Menu.OnMouseOver = function (sender) {
        return function(btn){
            var data= sender.Data;
            var itemdata = data[btn.id];
            if(itemdata.isShow==false)
                sender.ShowSubMenu(itemdata);
        };
    };
   
    //#endregion menu
    //#region windows
    h.Defui["h:windows"] = h.Defui["h:windows"] || {}; h.Windows = h.Defui["h:windows"];
    h.PageWindows = null;
    h.Windows.Init = function (e) {
        //if (e.id == undefined || e.id == "") { h.error("h:windows is not setting id"); }
        e.isInit = true;
        e.zIndex = 101;
        e.wmask = null;
        e.witems = new Array();
        e.TaskBox = null;
        h.Windows.CreateWMask(e);
    };
    h.Windows.InitTaskByListView = function (lv) {
        var ws = h.PageWindows;
        ws.TaskBox = lv;
        lv.isUnSelectedInOnClick = "false";
        lv.Data = ws.witems;
        lv.IsBind = false;
        lv.OnItemClick = function (lv, sender, i) {
            lv.Data[i].Show();
        }
        lv.Bind();
    };
    h.Windows.CreateWMask = function (e) {
        e.wmask = h.d.createElement("h:mask");
        e.wmask.style.zIndex = "100";
        var pagesize = h.GetPageSize();
        e.wmask.style.top = "0px";
        e.wmask.style.left = "0px";
        e.wmask.style.zIndex = "100";
        e.wmask.style.width = pagesize.ww + "px";
        e.wmask.style.height = pagesize.wh + "px";
        e.wmask.Show = function () {
            this.className = "";
            this.style.zIndex = h.PageWindows.zIndex+1;
            this.style.display = "";
        };
        e.wmask.ShowOpacityMask0 = function () {
            this.className = "OpacityMask0";
            this.style.display = "";
        };
        e.wmask.Hide = function () {
            this.style.display = "none";
            this.style.zIndex = 101;
        };
        e.wmask.ReSize = function () {
            var pagesize = h.GetPageSize();
            e.wmask.style.width = pagesize.ww + "px";
            e.wmask.style.height = pagesize.wh + "px";
        };
        e.wmask.Hide();
        e.appendChild(e.wmask);
    }
    h.Windows.InitDom = function () {
        var windows = g("windows");
        if (windows == null || windows == undefined || windows.length <= 0) {
            return;
        }
        h.Windows.Init(windows[0]);
        h.PageWindows = windows[0];
    };
    h.Windows.AddWindow = function (w) {
        var d = h.Windows.GetWindow(w.id);
        if (d == null) {
            h.PageWindows.witems[h.PageWindows.witems.length] = w;
            h.PageWindows.appendChild(w);
            var ws = h.PageWindows;
            if (ws.TaskBox != null) {
                ws.TaskBox.Data = ws.witems;
                ws.TaskBox.IsBind = false;
                ws.TaskBox.Bind();
            }
        }
    };
    h.Windows.GetWindow = function (id) {
        for (var w in h.PageWindows.witems) {
            if (h.PageWindows.witems[w].id == id)
                return h.PageWindows.witems[w];
        }
        return null;
    };
    h.Windows.GetWindowIndex = function (id) {
        for (var i = 0; i < h.PageWindows.witems.length; i++) {
            if (h.PageWindows.witems[i] != null) {
                if (h.PageWindows.witems[i].id == id)
                    return i;
            }
        }
        return -1;
    };
    h.Windows.ShowWindow = function (id) {
        var w = h.Windows.GetWindow(id);
        if (w == null)
            return null;
         w.Show();
    };
    h.Windows.HidWindow = function (id) {
        var w = h.Windows.GetWindow(id);
        w.Hid();
    };
    h.Windows.CloseWindow = function (id) {
        var index = h.Windows.GetWindowIndex(id);
        var w=null;
        if(index != -1)
        {
            w = h.PageWindows.witems[index];
            delete h.PageWindows.witems[index];
        }
        else
        {
            w = g("#"+id);
        }
        w.Hid();
    };
    h.Windows.OpenWindow = function (id) {
        var w = g("#" + id, h.PageWindows);
        h.Windows.AddWindow(w)
        w.Show();
    };
    h.Windows.CreateWindow = function (id, caption, content, hposition, type) {
        if (g("#" + id) != null) { h.error("This id is already in use"); return; }
        var e = h.d.createElement("h:window");
        e.id = id;
        e.OnLoadingHandle = function (sender) {
            if (e.type != null)
                e.type = type;
            if (hposition != null)
                e.hposition = new Position(e, hposition);
            e.caption = caption;
            e.content = content;
        };
        h.Window.Init(e);
        return e;
    };
    h.Defui["h:window"] = h.Defui["h:window"] || {}; h.Window = h.Defui["h:window"];
    h.Window.Init = function (e) {
        if (e.id == undefined || e.id == "") { h.error("h:window haven`t setting id"); }
        e.isInit = true;
        e.type = h.Attr(e, "type") ? h.Attr(e, "type") : "w"; //m,w
        e.caption = h.Attr(e, "caption") ? h.Attr(e, "caption") : "window";
        e.hposition = new Position(e, (h.Attr(e, "hposition") ? h.Attr(e, "hposition") : "0,0,800,500"));
        e.oldhposition = new Position(e, e.hposition.uncovert());
        e.isshowmask = h.Attr(e, "isshowmask") ? h.Attr(e, "isshowmask") : "false";
        e.iscenter = h.Attr(e, "iscenter") ? h.Attr(e, "iscenter") : "true";
        e.state = h.Attr(e, "state") ? h.Attr(e, "state") : "normal"; //min ,max,normal
        e.isactive = h.Attr(e, "isactive") ? h.Attr(e, "isactive") : "false";  // true,false
        e.minwidth = h.Attr(e, "minwidth") ? h.Attr(e, "minwidth") : "200";
        e.minheight = h.Attr(e, "minheight") ? h.Attr(e, "minheight") : "200";
        e.closeenable = h.Attr(e, "closeenable") ? h.Attr(e, "closeenable") : "true"; // true,false
        e.keygroup = h.Attr(e, "keygroup") ? h.Attr(e, "keygroup") : e.id;
        e.keyclosechar=h.Attr(e, "keyclosechar") ? h.Attr(e, "keyclosechar") : "SHIFT+F4";
        e.keyminchar=h.Attr(e, "keyminchar") ? h.Attr(e, "keyminchar") : "ESC";
        e.keymaxchar=h.Attr(e, "keymaxchar") ? h.Attr(e, "keymaxchar") : "SHIFT+X";
        e.style.zIndex = h.PageWindows.zIndex;

        e.content = "";
        var objs;
        if (e.caption === "window") {
            objs = g("caption", e);
            if (objs != null && objs.length > 0)
                e.caption = objs[0].innerHTML;
        }
        objs = g("content", e);
        if (objs != null && objs.length > 0)
            e.content = objs[0].innerHTML;
        e.mainId = e.id + "main";
        e.captionId = e.id + "title";
        e.contentId = e.id + "content";
        e.topBorderId = e.id + "topborder";
        e.bottomborderId = e.id + "bottomborder";
        e.resizebtnId = e.id + "resizebtn";
        e.maxbtnId = e.id + "maxbtn";
        e.minbtnId = e.id + "minbtn";
        e.closebtnId = e.id + "closebtn";
        h.Windows.AddWindow(e);
        if (e.OnLoadingHandle != null)
            e.OnLoadingHandle(e);
        if (e.iscenter === "true") {
            var wsize = h.GetPageSize();
            e.hposition.left = (wsize.ww - e.hposition.width) / 2;
            e.hposition.top = (wsize.wh - e.hposition.height) / 2;
        }
        e.hposition.Bind();
        if (e.type === "m")
            h.Window.InitModeWindow(e);
        else
            h.Window.InitWindow(e);
        if (e.isactive === "true") {
            e.style.display = "";
        }
        else{
             e.style.display = "none";
         }
         //#region 方法
         e.Show = function () {
            if(e.style.display == "") return;
            e.isactive = "true";
            if (e.isshowmask === "true")
                h.PageWindows.wmask.Show();
            else
               h.PageWindows.wmask.Hide();
            h.PageWindows.zIndex = h.PageWindows.zIndex + 1;
            e.style.zIndex = h.PageWindows.zIndex;
            e.style.display = "";
            h.key.ActiveGroup(e.keygroup);
        };
         e.Hid = function () {
            if(e.style.display=="none") return;
            e.isactive = "false";
            if (e.isshowmask === "true")
                h.PageWindows.wmask.Hide();
            e.style.display = "none";
            h.key.ActiveGroup();
        };
         //min ,max,normal
         e.SetState = function (state) {
            if (state == "min") {
                e.state = "min";
                e.Hid();
            }
            if (state == "max") {
                e.state = "max";
                e.isactive = "true";
                var pagesize = h.GetPageSize();
                e.oldhposition = new Position(e, e.hposition.uncovert());
                e.hposition.top = 0;
                e.hposition.left = 0;
                e.hposition.width = pagesize.ww;
                e.hposition.height = pagesize.wh;
                e.hposition.Bind();
                e.main.DoLayout();
            }
            if (state == "normal") {
                e.state = "normal";
                e.isactive = "true";
                e.hposition = new Position(e, e.oldhposition.uncovert());
                e.hposition.Bind();
                e.main.DoLayout(e.main);
            }
        };
         e.SetCaption = function (caption) {
            e.caption = caption;
            e.captionObj.html(e.caption);
         };
         e.SetContent = function (content) {
            e.content = content;
            e.contentObj.html(e.content);
            e.main.DoLayout();
        };
        e.SetPosition = function (hposition) {
            e.hposition = new Position(e, hposition);
            if (e.iscenter === "true") {
                var wsize = h.GetPageSize();
                e.hposition.left = (wsize.ww - e.hposition.width) / 2;
                e.hposition.top = (wsize.wh - e.hposition.height) / 2;
            }
            e.hposition.Bind();
            //if (e.type === "m")
            //    h.Window.InitModeWindow(e);
            //else
            //    h.Window.InitWindow(e);
            if (e.isactive === "true") {
                e.style.display = "";
            }
            if (e.closeenable == "false")
                h.Window.HidCloseBtn(e);
        };
        if(e.closeenable == "false")
            h.Window.HidCloseBtn(e);
        //#endregion 方法
        if (e.OnLoadHandle != null)
            e.OnLoadHandle(e);

    };
    h.Window.GetHtml = function (e) {
        var html = "<h:layout id='" + e.mainId + "' borderwidth='0,2,0,2' class='leftrightborder' >" +
                "<h:head borderwidth='2,0,0,0' hposition='0,0,*,25' class='top_border'  id='" + e.topBorderId + "'>" +
                "<h:layout borderwidth='0,0,0,0' class='title' >" +
                "<h:left borderwidth='0,0,0,0' class='title_label' id='" + e.captionId + "' >" + e.caption + "</h:left>" +
                "<h:right borderwidth='0,0,0,0' hposition='0,0,100,*' style='text-align: right;'>" +
                "<h:btn css='minbtn' csshover='minbtn_hover' id='" + e.minbtnId + "'></h:btn>&nbsp;<h:btn css='maxbtn' csshover='maxbtn_hover' id='" + e.maxbtnId + "'></h:btn>&nbsp;" +
                "<h:btn css='closebtn' csshover='closebtn_hover' id='" + e.closebtnId + "'></h:btn>&nbsp;" +
                "</h:right></h:layout>" +
                "</h:head>" +
                "<h:bottom borderwidth='0,0,2,0' class='bottom_border'  id='" + e.bottomborderId + "'>" +
                "<h:layout borderwidth='0,0,0,0' ><h:head borderwidth='1,1,1,1' class='content' id='" + e.contentId + "'>" + e.content + "</h:head>" +
                "<h:bottom borderwidth='0,0,0,0' hposition='0,0,*,25' class='bottom'>" +
                "<h:layout borderwidth='0,0,0,0' ><h:left borderwidth='0,0,0,0' ></h:left>" +
                "<h:right borderwidth='0,0,0,0' hposition='0,0,100,*' style='text-align:right;'><h:btn css='resizebtn' csshover='resizebtn' id='" + e.resizebtnId + "'></h:btn></h:right></h:layout></h:bottom></h:layout></h:bottom></h:layout>";
        return html;
    };
    h.Window.GetModelHtml = function (e) {
        var html = "<h:layout id='" + e.mainId + "' borderwidth='0,0,0,0' class='leftrightborder'>" +
                "<h:head id='' borderwidth='0,0,0,0' hposition='0,0,*,25' class='top_border'>" +
                "<h:layout borderwidth='0,0,0,0' class='title'>" +
                "<h:left borderwidth='0,0,0,0' class='title_label' id='" + e.captionId + "'>" + e.caption + "</h:left>" +
                "<h:right borderwidth='0,0,0,0' hposition='0,0,30,*' style='text-align: right;'>" +
                "<h:btn css='closebtn' csshover='closebtn_hover' id='" + e.closebtnId + "'></h:btn>&nbsp;" +
                "</h:right></h:layout>" +
                "</h:head>" +
                "<h:bottom borderwidth='1,0,0,0' class='modelContent' id='" + e.contentId + "'>" + e.content + "</h:bottom></h:layout>";
        return html;
    };
    h.Window.HidCloseBtn = function(e){
        var closeobj = g("#"+e.closebtnId);
        closeobj.style.display="none";
        h.addEvent(e.CloseBtn, "click", function(){});
        h.key.Addkey(e.keygroup,e.keyminchar,function(){});
        e.closeenable = "false";
    };
    h.Window.ShowCloseBtn = function(e){
        var closeobj = g("#"+e.closebtnId);
        closeobj.style.display="";
        h.addEvent(e.CloseBtn, "click", h.Window.CloseBtn_OnClick(e));
        h.key.Addkey(e.keygroup,e.keyminchar,h.Window.CloseBtn_OnClick(e));
        e.closeenable = "true";
        
    };
    h.Window.InitModeWindow = function (e) {
        e.innerHTML = h.Window.GetModelHtml(e);
        h.InitDom(e);
        e.main = g("#" + e.mainId, e);
        e.captionObj = g("#" + e.captionId, e);
        e.contentObj = g("#" + e.contentId, e);
        e.CloseBtn = g("#" + e.closebtnId, e);
        e.isshowmask = "true";
        e.main.pelem = e;
        e.main.DoLayout();
        h.addEvent(e.captionObj, "mousedown", h.Window.Caption_OnMouseDown(e));
        h.addEvent(e.captionObj, "click", h.Window.Caption_OnClick(e));
        h.addEvent(e.CloseBtn, "click", h.Window.CloseBtn_OnClick(e));
        h.key.Addkey(e.keygroup,e.keyminchar,h.Window.CloseBtn_OnClick(e));
 
    };
    h.Window.InitWindow = function (e) {
        e.innerHTML = h.Window.GetHtml(e);
        h.InitDom(e);
        e.main = g("#" + e.mainId, e);
        e.captionObj = g("#" + e.captionId, e);
        e.contentObj = g("#" + e.contentId, e);
        e.topborderObj = g("#" + e.topBorderId, e);
        e.bottomborderObj = g("#" + e.bottomborderId, e);
        e.ResizeBtn = g("#" + e.resizebtnId, e);
        e.MinBtn = g("#" + e.minbtnId, e);
        e.MaxBtn = g("#" + e.maxbtnId, e);
        e.CloseBtn = g("#" + e.closebtnId, e);
        e.main.pelem = e;
        e.main.DoLayout();
        h.addEvent(e.main, "mousedown", h.Window.LeftRightBorder_OnMouseDown(e));
        h.addEvent(e.captionObj, "mousedown", h.Window.Caption_OnMouseDown(e));
        h.addEvent(e.captionObj, "dblclick", h.Window.MaxBtn_OnClick(e));
        h.addEvent(e.captionObj, "click", h.Window.Caption_OnClick(e));
        h.addEvent(e.topborderObj, "mousedown", h.Window.TopBorder_OnMouseDown(e));
        h.addEvent(e.bottomborderObj, "mousedown", h.Window.BottomBorder_OnMouseDown(e));
        h.addEvent(e.ResizeBtn, "mousedown", h.Window.ResizeBtn_OnMouseDown(e));

        h.addEvent(e.MinBtn, "click", h.Window.MinBtn_OnClick(e));
        h.addEvent(e.MaxBtn, "click", h.Window.MaxBtn_OnClick(e));
        h.addEvent(e.CloseBtn, "click", h.Window.CloseBtn_OnClick(e));
        h.key.Addkey(e.keygroup,e.keyclosechar,h.Window.CloseBtn_OnClick(e));
        h.key.Addkey(e.keygroup,e.keyminchar,h.Window.MinBtn_OnClick(e));
        h.key.Addkey(e.keygroup,e.keymaxchar,h.Window.MaxBtn_OnClick(e));
    };
    h.Window.Caption_OnMouseDown = function (e) {
        return function () {
            var sender = h.GetEventArg(h.GetEvent());
            if (sender.id != e.captionId) { return; }
            if (e.isshowmask === "false")
                h.PageWindows.wmask.ShowOpacityMask0();
            g("iframe", e).each(function () { this.style.display = "none"; });
            e.DragData = {};
            var y = h.Page.MouseY - e.hposition.top;
            var x = h.Page.MouseX - e.hposition.left;
            h.Drag.SetData(e.DragData, function (dragData) {
                e.hposition.top = h.Page.MouseY - y;
                e.hposition.left = h.Page.MouseX - x;
                e.hposition.Bind();
            }, function (dragData) {
                if (e.isshowmask === "false")
                    h.PageWindows.wmask.Hide();
                g("iframe", e).each(function () { this.style.display = ""; });
            });
        };
    };
    h.Window.TopBorder_OnMouseDown = function (e) {
        return function () {
            var sender = h.GetEventArg(h.GetEvent());
            if (sender.id != e.topBorderId) { return; }
            //e.main.style.display = "none";
            if (e.isshowmask === "false")
                h.PageWindows.wmask.ShowOpacityMask0();
            g("iframe").each(function () { this.style.display = "none"; });
            h.Drag.SetData(e, function (d) {
                var p = e.hposition;
                p.height = p.height - (h.Page.MouseY - p.top);
                p.top = h.Page.MouseY;
                if (p.height < e.minheight) { p.height = e.minheight; }
                p.Bind();
            }, function (d) {
                if (e.isshowmask === "false")
                    h.PageWindows.wmask.Hide();
                g("iframe").each(function () { this.style.display = ""; });
                //e.main.style.display = "";
                e.main.DoLayout();
            });
        };
    };
    h.Window.LeftRightBorder_OnMouseDown = function (e) {
        return function () {
            var sender = h.GetEventArg(h.GetEvent());
            if (sender.id != e.mainId) { return; }
            //e.main.style.display = "none";
            if (e.isshowmask === "false")
                h.PageWindows.wmask.ShowOpacityMask0();
            g("iframe").each(function () { this.style.display = "none"; });
            var p = e.hposition;
            if (h.Page.MouseX > p.left - 5 && h.Page.MouseX < p.left + 5) {
                h.Drag.SetData({}, function (d) {
                    p.width = p.width - (h.Page.MouseX - p.left);
                    p.left = h.Page.MouseX;
                    if (p.width < e.minwidth) p.width = e.minwidth;
                    p.Bind();
                }, function (d) {
                    if (e.isshowmask === "false")
                        h.PageWindows.wmask.Hide();
                    g("iframe", e).each(function () { this.style.display = ""; });
                    //e.main.style.display = "";
                    e.main.DoLayout();
                });
            }
            else {
                h.Drag.SetData({}, function (d) {
                    var currentleft = p.left + parseInt(p.width);
                    p.width = parseInt(p.width) + (h.Page.MouseX - currentleft);
                    if (p.width < e.minwidth) p.width = e.minwidth;
                    p.Bind();
                }, function (d) {
                    if (e.isshowmask === "false")
                        h.PageWindows.wmask.Hide();
                    g("iframe").each(function () { this.style.display = ""; });
                    //e.main.style.display = "";
                    e.main.DoLayout();
                });

            }
        };
    };
    h.Window.BottomBorder_OnMouseDown = function (e) {
        return function () {
            var sender = h.GetEventArg(h.GetEvent());
            if (sender.id != e.bottomborderId)
            { return; }
            //e.main.style.display = "none";
            if (e.isshowmask === "false")
                h.PageWindows.wmask.ShowOpacityMask0();
            g("iframe").each(function () { this.style.display = "none"; });
            var p = e.hposition;
            h.Drag.SetData({}, function (d) {
                var currentTop = p.top + parseInt(p.height);
                p.height = parseInt(p.height) + (h.Page.MouseY - currentTop);
                if (p.height < e.minheight) p.height = e.minheight;
                p.Bind();
            }, function (d) {
                if (e.isshowmask === "false")
                    h.PageWindows.wmask.Hide();
                g("iframe").each(function () { this.style.display = ""; });
                //e.main.style.display = "";
                e.main.DoLayout();
            });
        };
    };
    h.Window.ResizeBtn_OnMouseDown = function (e) {
        return function () {
            var sender = h.GetEventArg(h.GetEvent());
            if (sender.id != e.resizebtnId)
            { return; }
            //e.main.style.display = "none";
            if (e.isshowmask === "false")
                h.PageWindows.wmask.ShowOpacityMask0();
            g("iframe").each(function () { this.style.display = "none"; });
            var p = e.hposition;
            h.Drag.SetData({}, function (d) {
                var currentTop = p.top + parseInt(p.height);
                var currentleft = p.left + parseInt(p.width);
                p.height = parseInt(p.height) + (h.Page.MouseY - currentTop);
                p.width = parseInt(p.width) + (h.Page.MouseX - currentleft);
                if (p.height < e.minheight) p.height = e.minheight;
                if (p.width < e.minwidth) p.width = e.minwidth;
                p.Bind();
                //h.layout.DoLayout(e.main);
            }, function (d) {
                if (e.isshowmask === "false")
                    h.PageWindows.wmask.Hide();
                g("iframe").each(function () { this.style.display = ""; });
                //e.main.style.display = "";
                e.main.DoLayout();
            });
        };
    };
    h.Window.MinBtn_OnClick = function (e) {
        return function () {
            e.SetState("min");
            h.key.ActiveGroup();
        };
    };
    h.Window.MaxBtn_OnClick = function (e) {
        return function () {
            if (e.state == "max")
                e.SetState("normal");
            else
                e.SetState("max");
             h.key.ActiveGroup(e.id);
            
        };
    };
    h.Window.Caption_OnClick = function (e) {
        return function () {
            h.key.ActiveGroup(e.id);
            h.PageWindows.zIndex = h.PageWindows.zIndex + 1;
            e.style.zIndex = h.PageWindows.zIndex;
            var index = h.Windows.GetWindowIndex(e.id);
            if(h.PageWindows.TaskBox !=null)
                h.PageWindows.TaskBox.Select(index);
        };

    };
    h.Window.CloseBtn_OnClick = function (e) {
        return function () {
            h.Windows.CloseWindow(e.id);
            h.key.ActiveGroup();
            if (h.PageWindows.TaskBox != null) {
                h.PageWindows.TaskBox.IsBind = false;
                h.PageWindows.TaskBox.Bind();
            }
        };
    };
    //#endregion windows
    //#endregion Definition dom UI Control Class

    // 发布框架对象。
    window._h = h; window._g = g; window.hdomext=h;
    h.ready(function () {
        h.Store.init();
        h.InitScrollBarWH();//设置滚动条宽度
        if (h.Page.InitHandle != null) {
            h.Page.InitHandle();
        }
       
        h.InitExtend();
        h.Windows.InitDom();
        h.InitDom();
        h.addEvent(d, "mousemove", h.Page.OnMouseMove);
        h.addEvent(d, "mouseup", h.Page.OnMouseUp);
        h.addEvent(d, "keydown", h.Page.OnKeyDown);
        h.addEvent(d,"click",h.Page.OnClick);
        //启动布局
        h.addEvent(window, "resize", h.Page.OnReSize);
        if (g("h:layout")[0] != undefined) {
            h.layout.LayoutWhileFun();
            h.addEvent(window, "resize", h.layout.LayoutWhileFun);
        }
        if (h.PageWindows != null) {
            if (h.PageWindows.wmask != undefined)
                h.addEvent(window, "resize", h.PageWindows.wmask.ReSize);
        }
        if (h.IsIE6) {
            window.onscroll = function () {
                h.PageWindows.wmask.style.top = d.documentElement.scrollTop + "px";
                h.PageWindows.wmask.style.left = d.documentElement.scrollLeft + "px";
            };
        }
        if (h.Page.OnLoadHandle != null) {
            h.Page.OnLoadHandle();
        }
        //完成布局启动
    });

})(window);

//+---------------------------------------------------   
//| 字符串转成日期类型    
//| 格式 MM/dd/YYYY MM-dd-YYYY YYYY/MM/dd YYYY-MM-dd   
//+---------------------------------------------------   
Date.StringToDate = function (DateStr)   
{    
   
    var converted = Date.parse(DateStr);   
    var myDate = new Date(converted);   
    if (isNaN(myDate))   
    {    
        //var delimCahar = DateStr.indexOf('/')!=-1?'/':'-';   
        var arys= DateStr.split('-');   
        myDate = new Date(arys[0],--arys[1],arys[2]);   
    }   
    return myDate;   
};   

//---------------------------------------------------   
// 判断闰年   
//---------------------------------------------------   
Date.prototype.isLeapYear = function()    
{    
    return (0==this.getYear()%4&&((this.getYear()%100!=0)||(this.getYear()%400==0)));    
};    
   
//---------------------------------------------------   
// 日期格式化   
// 格式 YYYY/yyyy/YY/yy 表示年份   
// MM/M 月份   
// W/w 星期   
// dd/DD/d/D 日期   
// hh/HH/h/H 时间   
// mm/m 分钟   
// ss/SS/s/S 秒   
//---------------------------------------------------   
Date.prototype.Format = function(formatStr)    
{    
    var str = formatStr;    
    var Week = ['日','一','二','三','四','五','六'];   
   
    str=str.replace(/yyyy|YYYY/,this.getFullYear());    
    str=str.replace(/yy|YY/,(this.getYear() % 100)>9?(this.getYear() % 100).toString():'0' + (this.getYear() % 100));    
   
    str=str.replace(/MM/,this.getMonth()>9?(this.getMonth()+1).toString():'0' + (this.getMonth()+1));    
    str=str.replace(/M/g,this.getMonth()+1);    
   
    str=str.replace(/w|W/g,Week[this.getDay()]);    
   
    str=str.replace(/dd|DD/,this.getDate()>9?this.getDate().toString():'0' + this.getDate());    
    str=str.replace(/d|D/g,this.getDate());    
   
    str=str.replace(/hh|HH/,this.getHours()>9?this.getHours().toString():'0' + this.getHours());    
    str=str.replace(/h|H/g,this.getHours());    
    str=str.replace(/mm/,this.getMinutes()>9?this.getMinutes().toString():'0' + this.getMinutes());    
    str=str.replace(/m/g,this.getMinutes());    
   
    str=str.replace(/ss|SS/,this.getSeconds()>9?this.getSeconds().toString():'0' + this.getSeconds());    
    str=str.replace(/s|S/g,this.getSeconds());    
   
    return str;    
};    
   
//+---------------------------------------------------   
//| 求两个时间的天数差 日期格式为 YYYY-MM-dd    
//+---------------------------------------------------   
Date.DaysBetween =function(DateOne,DateTwo)   
{    
    var OneMonth = DateOne.substring(5,DateOne.lastIndexOf ('-'));   
    var OneDay = DateOne.substring(DateOne.length,DateOne.lastIndexOf ('-')+1);   
    var OneYear = DateOne.substring(0,DateOne.indexOf ('-'));   
   
    var TwoMonth = DateTwo.substring(5,DateTwo.lastIndexOf ('-'));   
    var TwoDay = DateTwo.substring(DateTwo.length,DateTwo.lastIndexOf ('-')+1);   
    var TwoYear = DateTwo.substring(0,DateTwo.indexOf ('-'));   
   
    var cha=((Date.parse(OneMonth+'/'+OneDay+'/'+OneYear)- Date.parse(TwoMonth+'/'+TwoDay+'/'+TwoYear))/86400000);    
    return Math.abs(cha);   
};   
   
//+---------------------------------------------------   
//| 日期计算   
//+---------------------------------------------------   
Date.prototype.DateAdd = function(strInterval, Number) {    
    var dtTmp = this; 
    var tempDate = new Date();
    switch (strInterval) {    
        case 's' :tempDate.setTime(dtTmp.getTime() + (1000 * Number));break; 
        case 'n' :tempDate.setTime(dtTmp.getTime() + (60000 * Number));break;  
        case 'h' :tempDate.setTime(dtTmp.getTime() + (3600000 * Number));break; 
        case 'd' :tempDate.setTime(dtTmp.getTime() + (86400000 * Number));break;
        case 'w' :tempDate.setTime(dtTmp.getTime() + ((86400000 * 7) * Number));break;  
        case 'q' :tempDate.setTime(dtTmp.getTime()+((3*86400000*30)*Number));break;   
        case 'm' :tempDate.setTime(dtTmp.getTime()+((86400000*30)*Number));break;  
        case 'y' :tempDate.setTime(dtTmp.getTime()+((86400000*365)*Number));break; 
    } 
    return tempDate;
};   
   
//+---------------------------------------------------   
//| 比较日期差 dtEnd 格式为日期型或者 有效日期格式字符串   
//+---------------------------------------------------   
Date.prototype.DateDiff = function(strInterval, dtEnd) {    
    var dtStart = this;   
    if (typeof dtEnd == 'string' )//如果是字符串转换为日期型   
    {    
        dtEnd = Date.StringToDate(dtEnd);   
    }   
    switch (strInterval) {    
        case 's' :return parseInt((dtEnd - dtStart) / 1000);   
        case 'n' :return parseInt((dtEnd - dtStart) / 60000);   
        case 'h' :return parseInt((dtEnd - dtStart) / 3600000);   
        case 'd' :return parseInt((dtEnd - dtStart) / 86400000);   
        case 'w' :return parseInt((dtEnd - dtStart) / (86400000 * 7));   
        case 'm' :return (dtEnd.getMonth()+1)+((dtEnd.getFullYear()-dtStart.getFullYear())*12) - (dtStart.getMonth()+1);   
        case 'y' :return dtEnd.getFullYear() - dtStart.getFullYear();   
    }   
};   
   
//+---------------------------------------------------   
//| 日期输出字符串，重载了系统的toString方法   
//+---------------------------------------------------   
Date.prototype.toString = function(showWeek)   
{    
    var myDate= this;   
    var str = myDate.toLocaleDateString();   
    if (showWeek)   
    {    
        var Week = ['日','一','二','三','四','五','六'];   
        str += ' 星期' + Week[myDate.getDay()];   
    }   
    return str;   
};   
   
//+---------------------------------------------------   
//| 日期合法性验证   
//| 格式为：YYYY-MM-DD或YYYY/MM/DD   
//+---------------------------------------------------   
Date.IsValidDate=function(DateStr)   
{   
     var sDate=DateStr.replace(/(^\s+|\s+$)/g,''); //去两边空格;   
     if(sDate=='') return true;   
     //如果格式满足YYYY-(/)MM-(/)DD或YYYY-(/)M-(/)DD或YYYY-(/)M-(/)D或YYYY-(/)MM-(/)D就替换为''   
     //数据库中，合法日期可以是:YYYY-MM/DD(2003-3/21),数据库会自动转换为YYYY-MM-DD格式
      
     var s = sDate.replace(/[\d]{ 4,4 }[\-/]{ 1 }[\d]{ 1,2 }[\-/]{ 1 }[\d]{ 1,2 }/g,'');   
     if (s=='') //说明格式满足YYYY-MM-DD或YYYY-M-DD或YYYY-M-D或YYYY-MM-D   
     {   

         var t=new Date(sDate.replace(/\-/g,'/'));   
         var ar = sDate.split(/[-/:]/);   

         if(ar[0] != t.getYear() || ar[1] != t.getMonth()+1 || ar[2] != t.getDate())   

         {   
             //alert('错误的日期格式！格式为：YYYY-MM-DD或YYYY/MM/DD。注意闰年。');   
             return false;  
             
         }   
     }   
     else   
     {   
         //alert('错误的日期格式！格式为：YYYY-MM-DD或YYYY/MM/DD。注意闰年。');   
         return false;   
     }   
     return true;   
};      
   
//+---------------------------------------------------   
//| 日期时间检查   
//| 格式为：YYYY-MM-DD HH:MM:SS   
//+---------------------------------------------------   
Date.CheckDateTime = function(str)   
{    
    var reg = /^(\d+)-(\d{ 1,2 })-(\d{ 1,2 }) (\d{ 1,2 }):(\d{ 1,2 }):(\d{ 1,2 })$/;    
    var r = str.match(reg);    
    if(r==null)return false;    
    r[2]=r[2]-1;    
    var d= new Date(r[1],r[2],r[3],r[4],r[5],r[6]);    
    if(d.getFullYear()!=r[1])return false;    
    if(d.getMonth()!=r[2])return false;    
    if(d.getDate()!=r[3])return false;    
    if(d.getHours()!=r[4])return false;    
    if(d.getMinutes()!=r[5])return false;    
    if(d.getSeconds()!=r[6])return false;    
    return true;    
};    
   
//+---------------------------------------------------   
//| 把日期分割成数组   
//+---------------------------------------------------   
Date.prototype.toArray = function()   
{    
    var myDate = this;   
    var myArray = Array();   
    myArray[0] = myDate.getFullYear();   
    myArray[1] = myDate.getMonth();   
    myArray[2] = myDate.getDate();   
    myArray[3] = myDate.getHours();   
    myArray[4] = myDate.getMinutes();   
    myArray[5] = myDate.getSeconds();   
    return myArray;   
};   
   
//+---------------------------------------------------   
//| 取得日期数据信息   
//| 参数 interval 表示数据类型   
//| y 年 m月 d日 w星期 ww周 h时 n分 s秒   
//+---------------------------------------------------   
Date.prototype.DatePart = function(interval)   
{    
    var myDate = this;   
    var partStr='';   
    var Week = ['日','一','二','三','四','五','六'];   
    switch (interval)   
    {    
        case 'y' :partStr = myDate.getFullYear();break;   
        case 'm' :partStr = myDate.getMonth()+1;break;   
        case 'd' :partStr = myDate.getDate();break;   
        case 'w' :partStr = Week[myDate.getDay()];break;   
        case 'ww' :partStr = myDate.WeekNumOfYear();break;   
        case 'h' :partStr = myDate.getHours();break;   
        case 'n' :partStr = myDate.getMinutes();break;   
        case 's' :partStr = myDate.getSeconds();break;   
    }   
    return partStr;   
};   
   
//+---------------------------------------------------   
//| 取得当前日期所在月的最大天数   
//+---------------------------------------------------   
Date.prototype.MaxDayOfDate = function()   
{    
    var myDate = this;   
    var ary = myDate.toArray();   
    var date1 = (new Date(ary[0],ary[1]+1,1));   
    var date2 = date1.DateAdd(1,'m',1);   
    var result = dateDiff(date1.Format('yyyy-MM-dd'),date2.Format('yyyy-MM-dd'));   
    return result;   
};   
   
//+---------------------------------------------------   
//| 取得当前日期所在周是一年中的第几周   
//+---------------------------------------------------   
Date.prototype.WeekNumOfYear = function()   
{    
    var myDate = this;   
    var ary = myDate.toArray();   
    var year = ary[0];   
    var month = ary[1]+1;   
    var day = ary[2];   
    document.write('< script language=VBScript\> \n');   
    document.write("myDate = DateValue('"+month+'-'+day+'-'+year+"') \n");   
    document.write("result = DatePart('ww', myDate) \n");   
    document.write(' \n');   
    return result;   
};
//++++++++++++++String 对象扩展  ++++++++++++++++++++++
String.Format = function(string)
{
    var args = arguments;
    var pattern = new RegExp("%([0-9]+)", "g");
    return String(string).replace(pattern, function (match, index) 
    {
        if (index == 0 || index >= args.length)
            throw "Invalid index in format string";
        return args[index]; 
    }); 
};
String.prototype.Trim = function(oldstr,nstr) 
{ 
    if(oldstr == null || oldstr == undefined) oldstr = "\s";
    if(nstr == null || nstr == undefined) nstr = "";
    var re = new RegExp("(^"+oldstr+"*)|("+oldstr+"*$)","g");
    return this.replace(re, nstr); 
} 
String.prototype.LTrim = function(oldstr,nstr) 
{ 
    if(oldstr == null || oldstr == undefined) oldstr = "\s";
    if(nstr == null || nstr == undefined) nstr = "";
    var re = new RegExp("(^"+oldstr+"*)","g");
    return this.replace(re, nstr); 
} 
String.prototype.RTrim = function(oldstr,nstr) 
{ 
     if(oldstr == null || oldstr == undefined) oldstr = "\s";
    if(nstr == null || nstr == undefined) nstr = "";
    var re = new RegExp("("+oldstr+"*$)","g");
    return this.replace(re, nstr); 
} 

